Skip to content

[codex] Add invalid tool call recovery hook#32

Closed
gold-silver-copper wants to merge 1 commit into
mainfrom
codex/invalid-tool-call-hooks
Closed

[codex] Add invalid tool call recovery hook#32
gold-silver-copper wants to merge 1 commit into
mainfrom
codex/invalid-tool-call-hooks

Conversation

@gold-silver-copper

Copy link
Copy Markdown
Owner

Summary

  • Add InvalidToolCallHookAction and PromptHook::on_invalid_tool_call for model-emitted unknown or disallowed tool calls.
  • Preserve the default fail-fast behavior by returning PromptError::UnknownToolCall unless the hook opts into recovery.
  • Allow hooks to return retry feedback as a synthetic tool result, continuing the prompt loop without executing invalid tool calls or peer tool calls from the invalid assistant turn.
  • Wire the hook into non-streaming prompts, completed streaming tool calls, and streaming tool-name deltas while keeping invalid calls away from normal on_tool_call and tool execution.
  • Add regression coverage for non-streaming retry, streaming completed-call retry, and streaming name-delta retry.

Notes

This builds on the tool-call validation added in #31 / upstream 0xPlaygrounds#1823. The default remains strict fail-fast; recovery is opt-in through the new hook action.

Validation

  • cargo fmt
  • cargo test -p rig-core agent::prompt_request:: -- --nocapture
  • cargo check -p rig-core
  • git diff --check

@gold-silver-copper gold-silver-copper marked this pull request as ready for review May 28, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant