withTool / with_tool wraps your tool callback, emits telemetry, and optionally evaluates guardrails before execution.
When you finish this page, tool calls inside a run will be traced with action and resource metadata.
Basic tool instrumentation
What you’ll see
Anagent.tool.called event in the run timeline with tool name, action type, resource type, and environment.
Quick start with inference
For monitor mode, you can omitaction and resource — Apie infers them from the tool name:
| Tool name pattern | Inferred action | Inferred resource | Risk |
|---|---|---|---|
deploy, release | execute | deployment_event | high |
vault, secret | read | secret | critical |
db.update, postgres | update | database_record | high |
github.merge | merge | code_repository | high |
search, read | read | varies | low |
Production metadata
Before enabling Enforce mode, provide explicit metadata for every risky tool:Guard non-tool actions
For actions that aren’t tool calls — deploying, sending email, modifying config — usewithGuard:
Integration helpers
Framework helpers wrapwithTool with sensible defaults:
Next steps
Action and resource metadata
Deep dive on the metadata model.
Monitor mode
Observe guardrail evaluations without blocking.
