Skip to content

feat(agent): optionally preserve native parallel tool calls - #2283

Open
Zeng-Weijun wants to merge 1 commit into
THUDM:mainfrom
Zeng-Weijun:codex/openai-adapter-parallel-tool-calls-20260818
Open

feat(agent): optionally preserve native parallel tool calls#2283
Zeng-Weijun wants to merge 1 commit into
THUDM:mainfrom
Zeng-Weijun:codex/openai-adapter-parallel-tool-calls-20260818

Conversation

@Zeng-Weijun

Copy link
Copy Markdown

Summary

The OpenAI agent adapter currently truncates every parsed tool-call turn to the first call so clients that drop extra calls can replay history. That behavior prevents native clients which faithfully echo parallel calls from executing and training all model-selected actions.

This adds an opt-in preserve_parallel_tool_calls=True constructor flag. The default remains unchanged for existing Codex-style clients. In native mode, both the OpenAI wire reply and the trajectory-manager message retain the complete ordered call list.

Why the opt-in is replay-safe

The native client echoes all tool_calls in its next Chat Completions request. _translate_messages removes only wire correlation IDs and JSON-decodes arguments, reproducing the exact manager message recorded for the preceding turn. The regression test checks this equality for two calls and also locks the legacy default at one call.

Validation

  • ruff check slime/agent/adapters/openai.py tests/test_agent/test_adapters.py
  • CUDA_VISIBLE_DEVICES= USE_TORCH=0 python -m pytest -q tests/test_agent
  • 65 passed, 1 skipped on a registered CPU worker

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