Repository navigation
fix(runtime): resume pending tools in Codex and PiAgent - #1197
Merged
yaozheng-fang merged 2 commits intoNov 2, 2026
Merged
Conversation
yaozheng-fang
approved these changes
Nov 2, 2026
yaozheng-fang
approved these changes
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Codex and PiAgent could continue their model loops on a pending tool placeholder, then replay the original user request when the external tool result arrived. This could produce premature answers or repeated tool calls. Pause the external turn only after ADK finishes the initial tool execution and returns no response, and resume from the supplied
functionResponsewhile retaining conversation and tool history.The bridges use ADK's existing long-running/deferred-tool semantics. Tools that return an immediate result still continue normally. Public Agent parameters and event schemas are unchanged; model callbacks, usage/state bookkeeping, cancellation, stream errors, and Codex thread persistence keep their existing paths. Pi prompts now retain structured tool calls/results, and Codex current-message-only prompts retain tool results when resuming a saved thread.
The permit-cleanup regression checks tool-setup error propagation and subsequent admission from another task without imposing a 50 ms deadline on unrelated workspace initialization. Admission/setup timeout behavior remains covered by its dedicated tests; production timeout behavior is unchanged.
Validation
Tested on macOS with Python 3.12, Google ADK 2.7.1, and
openai-codex0.159.2 (2026-11-02):uv run --extra dev --extra codex --extra sandbox pre-commit run --all-files: pass, including Ruff and secret scans.CODEX_RUN_SMOKE=1: 22 passed; two database-backed cases skipped because database URLs were not configured. The new real-process pending-tool → external-result → continuation smoke also passed.extensionsextra (llama_index). No runtime tests failed.Regressions cover asynchronous tool initialization, no-result versus immediate-result behavior, ordinary tools, duplicate/stale history, Pi's actual local tool-bridge subprocess, external-result continuation over multiple Codex turns, and safe process retirement followed by thread restoration/reuse.
Compatibility and limits
Callers continue supplying the external result with the original function-call ID through the standard ADK protocol. The pending event does not claim the tool completed. Interrupted Codex bridge processes follow the existing retirement policy; the stored thread resumes in a replacement process and can subsequently be reused. A real Pi/model smoke was not run; Pi was verified with the real local bridge and a deterministic RPC subprocess. SDK package versioning remains tag-derived.