Tool Execution Lifecycle
How an authorized decision becomes exactly one adapter run. Claiming, argument binding, deadlines, completion, failure, and repeat calls.
Authorization records a decision. Execution turns an allow, or an approved require_approval, into one run of a registered adapter. The lifecycle is designed so a side effect happens at most once, even across crashes, timeouts, and retries.
The execute request
{
"decision_id": "7f1c2a9e-…",
"idempotency_key": "idem-5f0d2c8e9a1b4c7d",
"approval_id": "3b9e…",
"arguments": { "headers": { "Accept": "application/json" } }
}| Field | Required | Meaning |
|---|---|---|
decision_id | yes | The decision returned by authorize |
idempotency_key | yes | Must equal the key used at authorize |
approval_id | only for require_approval | The approved approval request. Refused for an allow decision |
arguments | for adapters that use arguments | The same arguments that were authorized. Omitted means {} |
Execute is signed exactly like authorize, with a fresh nonce.
States
Step by step
Load and check the decision
The gateway authenticates the request, then loads the decision for the authenticated agent in its organization. A decision belonging to another agent is 404 not_found.
- Idempotency key mismatch →
409 conflict. deny→403 forbidden("decision is deny").require_approvalwithoutapproval_id→409 approval_required.allowwith anapproval_id→409 conflict.
Find the adapter and bind the arguments
The tool must have a registered adapter that supports the operation, or the response is 501 not_implemented and nothing is claimed. For adapters that use arguments, such as http.request, the gateway canonicalizes the presented arguments, hashes them, and compares the hash with the one stored at authorize. A mismatch is 409 conflict ("arguments do not match the decision").
Raw arguments are never stored, because tool arguments often carry secrets. Binding by hash lets the gateway prove that what runs is what policy saw.
The adapter then validates the call without side effects, for example checking that the URL is canonical and the host is allowed. A rejection is 400 validation_failed.
Claim
In one transaction the gateway locks the execution row and:
- Returns the stored result if the execution already completed.
- Refuses with
409 conflictif a previous attempt was already dispatched without a recorded outcome. - Consumes the approval if one was presented. See Human approvals.
- Checks the tool's circuit. An open circuit returns
503 circuit_openand rolls back, so the approval stays usable. - Records
dispatched_atand the adapter name, and commits.
Run
The adapter runs outside any transaction, with its deadline: two seconds by default, or the adapter's own (five seconds by default for http.request, up to 30). Keeping the run outside the transaction means a failed commit can never cause a second run.
Analyze (optional)
When the gateway has INTELLIGENCE_URL, the strings in the arguments and result are sent to the intelligence engine. The report is attached as analysis. It never changes the outcome. See Prompt injection analysis.
Complete or fail
A second transaction records the outcome:
- Success. Status
completed, the redacted result, and atool.executedevent. If analysis flagged the content, one alert per rule and acontent.flaggedevent are written in the same transaction. - Failure. Status
failed, the failure kind (timeout,rejected, oradapter_error), and atool.failedevent. Adapter failures other than validation rejections count toward the circuit.
The first execute returns the live result. A timeout surfaces as 500 internal_error with the message "tool adapter timed out".
Repeat calls
| Situation | Response | Adapter called? |
|---|---|---|
| Execution completed | 200 with the stored, redacted result | No |
| Execution failed | 409 conflict | No |
| Dispatched but outcome unknown (crash) | 409 conflict | No |
| Circuit was open on the previous try | Claim was rolled back; retry is allowed | Yes, once |
A retry after a timeout or crash requires a new authorize. This trades a little availability for a hard guarantee that a side effect is never repeated.
In the SDKs
call_tool / callTool performs authorize and, only on allow, execute with the same arguments. To execute an approved decision yourself:
executed = client.execute(
decision.decision_id,
decision.idempotency_key,
approval_id=decision.approval_id,
arguments=arguments, # exactly what you authorized
)Implementation references
Was this page helpful?
Policy Evaluation
The policy document format, the precedence rules that combine organization and agent policies, resource rules, and an interactive playground.
Budgets and Limits
Per-agent request, tool-call, and token budgets, size limits, adapter deadlines, circuit breakers, and behavioral incidents.