Skip to content

fix(runtime): resume pending tools in Codex and PiAgent - #1197

Merged
yaozheng-fang merged 2 commits into
volcengine:mainfrom
evanlowe:fix/runtime-long-running-tools
Nov 2, 2026
Merged

yaozheng-fang merged 2 commits into
volcengine:mainfrom
evanlowe:fix/runtime-long-running-tools

Conversation

@evanlowe

@evanlowe evanlowe commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

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 functionResponse while 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-codex 0.159.2 (2026-11-02):

  • uv run --extra dev --extra codex --extra sandbox pre-commit run --all-files: pass, including Ruff and secret scans.
  • Final local runtime regression after the CI timing fix: 696 passed, 39 skipped, 4 expected failures. The affected Codex turn-contract suite passed all 45 tests; pre-commit also passed again.
  • Real Codex process smoke suite, run sequentially with 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.
  • Real-model Codex two-turn probe: passed, 72,734 total tokens; the ADK tool executed once and the next turn retained the workspace/result.
  • Full default regression with two workers: 8,070 passed, 56 skipped, 4 expected failures, 6 failed. All six failures are existing Harness knowledge-base/long-term-memory tests that require the uninstalled extensions extra (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.

@yaozheng-fang
yaozheng-fang merged commit 6011ddf into volcengine:main Nov 2, 2026
14 checks passed
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.

2 participants