Skip to content

Tool Failures and Continuation

One Turn, One Tool Call traces a successful command. This chapter follows a narrower failure case. The mock model calls update_plan with a valid JSON object that omits its required plan field. Codex can report that validation error and make another model request within the same turn. Argument type · Fixture call

Evidence. Source and upstream integration fixture inspected for Codex CLI 0.172.0. The fixture scripts the model’s response to the failure. A separate pinned CLI run reproduced the parse error under the original call ID in request two. Run the plan-error probe

At this revision the base configuration leaves update_plan disabled. The upstream fixture sets the core flag directly. The CLI probe uses the equivalent TOML setting in its temporary home and verifies that request one actually declares the tool. The handler also checks the active mode before parsing. Config cases · Fixture setup · Handler mode check

[tools.update_plan]
enabled = true
  1. Reject the arguments before emitting a plan update. PlanHandler deserializes the function arguments into UpdatePlanArgs. The missing field yields a RespondToModel error. The handler emits PlanUpdate only after parsing succeeds. Handler and parser
  2. Turn the error into a tool observation. The direct tool runtime converts the nonfatal error to a FunctionCallOutput with the original call ID and the error text. The Rust payload also carries success = Some(false). Its serializer writes the body as the wire output, so the provider request carries the error text. Error handling · Failure output · Payload serialization
  3. Record it and continue. The response handler queues the invocation and marks follow-up work. The turn drains the resulting output into history. The next sampling iteration reads an updated history snapshot. Queue and follow-up · Record the output · Next history snapshot

The second request contains an item shaped like this. The full error text includes parser details.

{
"type": "function_call_output",
"call_id": "plan-tool-invalid",
"output": "failed to parse function arguments: missing field ..."
}

The test waits for TurnComplete, asserts that no PlanUpdate event occurred, then inspects the second provider request. The lookup checks the original call ID. The test requires the parse-error text and also checks that a success flag is false if the captured representation supplies one. Its second model response is scripted to complete the turn. Output lookup · Event and request assertions

A process exit after execution is a different failure stage. The direct runtime also has a fatal branch that returns a CodexErr::Fatal from the tool future. Cancellation can produce an aborted tool result. The trace above establishes continuation for this validation error. Fatal branch · Aborted results

Check whether the call reached a handler, whether the handler changed state, and what arrived back in the next request. This fixture reaches argument validation. It emits no checklist update and returns an error string tied to the call. In a separate shell test, a command that cannot be found is accepted by the execution layer as a process result. The two tests inspect different failure stages. Validation fixture · Command-not-found case

A proposed shell command can also stop while Codex is waiting for an approval reply. App Server matches the request to its thread, turn, and command item. Two upstream cases pass different replies to the same fixture. Request identity · Decision mapping

Client reply Completed command status Text found in a provider request
Explicit decline Declined rejected by user
Object with an unexpected reply shape Failed approval request failed

In both cases the fixture checks that the completed command item has the original item ID, an absent exit code, and absent aggregated output. It searches the captured Responses request bodies for the reason. That search establishes the presence of the text. The earlier plan-error fixture makes the stronger association between an output item and its call ID. Cases · Command and provider assertions

A tool hook can act before execution or change what the model sees afterward. Compare two synchronous hook fixtures.

Hook What the fixture observes
PreToolUse denies a proposed git init in a temporary directory No .git marker exists afterward. The second provider request contains the pre-hook denial under the original call ID. Command · Assertions
PostToolUse blocks the output of printf blocked-output The hook input contains the actual stdout, blocked-output. The output item in the second request contains the hook’s reason. Command · Assertions

A model-visible rejection alone leaves execution ambiguous. Inspect the side effect or the hook input alongside the captured request to tell these cases apart.

Do field-specific validation errors help a model recover within one attempt? Script the same bad call and return either a short generic rejection or an error naming the missing field. Hold the task, schema, and model fixed. Measure whether the next action supplies valid arguments, asks for missing user input, or gives up.

  1. Which event would indicate that the checklist update took effect?
  2. Which item lets the model associate the validation error with its rejected call?
  3. If a provider request carries a hook’s rejection, what evidence would tell you the command actually ran?

Answers. PlanUpdate indicates an accepted checklist update. The function_call_output ties the error to the call through call_id. In the post-hook fixture, the hook input contains the command’s actual stdout. In the pre-hook fixture, the test checks for the absence of the command’s expected side effect.

Continue with Steering an Active Turn to see how a client adds user input during an active turn.