Skip to content

Tool Execution Pipeline

A tool call should be explainable even when it fails before execution. Agent Tool therefore models the pipeline as a sequence of facts, not a single call() function.

Phases

PhasePurposeTerminal failures
resolve_toolFind a declaration by name or alias inside the current surface.unknown_tool, blocked_tool, schema_not_loaded.
parse_schemaValidate model_input against the model-facing schema.schema_validation_failed.
validate_valuesRun tool-specific value and IO preflight checks.invalid_arguments, setup_required, sandbox_violation.
prepare_observable_inputBuild a normalized copy for hooks, permission UI, SDK streams, and transcripts.input_mutation_failed.
pre_hooksLet hooks add context, progress, updated input, stop requests, or permission results.hook_blocked, hook_failed.
permissionResolve allow/ask/deny/passthrough through policy, rules, classifiers, or human approval.permission_denied, approval_rejected, policy_blocked.
scheduleQueue or run according to concurrency and ordering policy.canceled, sibling_canceled.
executeCall the native executor with timeout, abort signal, sandbox, credentials, and progress callback.execution_failed, timeout, dependency_unavailable.
map_resultConvert native output into the model-facing result envelope.result_mapping_failed.
post_hooksLet hooks enrich context, emit audit messages, or update protocol-specific outputs.post_hook_failed, hook_blocked.
persist_resultInline, preview, persist, redact, or link result bytes.result_too_large, result_redacted.
emit_terminalEmit terminal result and events.none; even errors should be represented.

Normal failures are results

Permission denial, user rejection, schema validation failure, missing tool, streaming fallback, and sibling cancellation SHOULD become terminal tool_result records with is_error: true. They should not disappear as exceptions that only the runtime can see.

Result mapping once

Map a native result into a model-facing result exactly once before generic persistence. If a protocol-specific post hook owns output mutation, record that mutation and remap after the hook. Avoid repeatedly serializing the same output differently across retries or resume.

Context modifiers

A tool MAY return a context modifier. The scheduler must say whether context modifiers are honored for concurrent tools. If a runtime cannot safely merge concurrent context changes, it SHOULD reject or defer those modifiers rather than apply them nondeterministically.

Draft standard for portable agent tool declarations, runtime interfaces, invocations, progress, results, permissions, scheduling, and audit refs.