Repository navigation
Preserve OpenCode tool-result history on third-party transparent Responses routes #193
Description
Outcome
Preserve OpenCode client-owned tool history on compatible third-party transparent Responses routes so Volc GLM-5.2 consumes one successful tool result and completes instead of repeating the tool loop.
Dependencies
Native blocker: #190. The #190 calibration records the stable 0.1.6 OpenCode/Volc failure as excessive_tool_loop; this Issue's candidate is the first required all-green twelve-round baseline. It consumes production-managed client configuration from #194 through #190.
Required design
- Determine the real OpenCode endpoint, managed selector, canonical model, downstream format, and upstream format from Expose headless managed-client config materialization for isolated runners #194 materialization/readback plus sanitized Gateway diagnostics before changing payload handling.
- Preserve compatible client-owned standard Responses
function_calland pairedfunction_call_outputitems, call IDs, names, arguments, outputs, status, and ordering byte- or semantic-transparently on same-format routes. - Restrict rewriting/normalization to records proven Codex-internal or explicit format-conversion paths. Preserve the established compatibility behavior for internal multi-agent, node REPL, compaction, tool-search, and native
apply_patchrecords. - Do not globally take ownership of external-client tool loops, retries, terminals, or fallback policy.
- Add bounded observation/error classification so repeated successful duplicate calls fail closed as
excessive_tool_loopbefore hundreds of rounds, without masking the transparent-payload defect.
Acceptance
- Focused tests prove a standard function call and paired result remain structured, ordered, and paired through the real transparent Volc Responses boundary.
- Compatible transparent payloads remain byte- or semantic-identical; translation occurs only on explicit Responses/Chat conversion paths.
- Model remap, store policy, supported message normalization, developer-role policy, boolean JSON Schema normalization, and genuine internal-item compatibility remain unchanged.
- No provider/model fallback, no broad removal of internal protections, no new Responses/Chat conversion, and no global tool-loop ownership.
- Real OpenCode
1.18.4uses the production-managed Volcglm-5.2selector/route, executes one random sentinel read-only tool, consumes its non-empty result, and produces one terminal completion withrequest_complete=200, no duplicate call/output, fallback, or reconnect. - The full twelve-round matrix is all green on the same candidate SHA. Official rounds use
gpt-5.6-luna; third-party rounds use Volcglm-5.2; no Kimi K3, Sol, Ollama, or substitute provider is allowed.
Hotset and gates
Expected code boundary: src-python/codex_proxy.py and focused routing tests; bounded-loop runner tests may update the #190 scripts/fixtures after #190 has merged.
Required gates: targeted tests, full python -m pytest -q, git diff --check, report-only quality gates, exact-SHA Actions, strict heavy review, Debug build, and authoritative VM evidence. Squash to dev only.
Activity
NOirBRight commentedon Jul 20, 2026
Regression provenance confirmed:
b0a7c69b1692b8633c4c2b45c0e4e03d7a1e2088(fix: sanitize OpenAI compaction items across all request paths).compaction,compaction_trigger, and other genuinely internal items from reaching third-party providers after model switching._rewrite_internal_input_items()on every non-official transparent request.INTERNAL_INPUT_ITEM_TYPESset also contains standard Responsesfunction_callandfunction_call_output, so the sanitizer's classification boundary is wider than the problem it was meant to solve.The fix should narrow semantic ownership, not special-case OpenCode by user agent:
function_call/function_call_outputremain structured by default on same-format transparent routes.NOirBRight commentedon Jul 21, 2026
{ "contract": { "acceptance": [ "The real OpenCode-to-Gateway endpoint and format are demonstrated from production-managed configuration and sanitized diagnostics before payload handling changes.", "A standard Responses function_call and paired function_call_output remain structured, paired, ordered, and byte- or semantic-equivalent across the transparent Volc Responses boundary.", "Model remap, store policy, supported message normalization, developer-role policy, boolean JSON Schema normalization, and genuine Codex-internal compatibility remain unchanged.", "Repeated successful duplicate calls terminate within a tested bound as excessive_tool_loop without fallback, broad internal-protection removal, or new Responses/Chat conversion.", "No Issue #190 runner, fixture, documentation, GUI, credential, or host-evidence path changes occur in this implementation.", "After Issue #190 merges, the exact final candidate is refreshed on dev and the complete twelve-round matrix is all green: Official gpt-5.6-luna and Volc glm-5.2 only, one real sentinel read, one terminal, one request_complete=200, and no fallback, duplicate output, or unclassified reconnect.", "Targeted tests, full python -m pytest -q, git diff --check, report-only quality gates, exact-SHA Actions, strict heavy review, Debug build, and authoritative host evidence pass for the final refreshed SHA." ], "change_claims": { "paths": [ "src-python/codex_proxy.py", "tests/test_routing.py", "tests/test_chat_completions_gateway.py" ], "resources": [ "gateway-transparent-responses" ] }, "dependencies": { "dispatch_after": [ 190 ], "merge_after": [ 190 ] }, "design": [ "Implement the OpenCode/Volc transparent Responses tool-history correction now from the current dev base, using the production managed-client seam already merged by Issue #194 to determine endpoint, selector, canonical model, and route format.", "Keep this implementation write set strictly in the Python Gateway and focused routing tests. Do not edit the Issue #190 runner, fixtures, or host evidence resources; the existing foundation supplies the later real-client gate.", "Preserve compatible standard Responses function_call and paired function_call_output items, identifiers, names, arguments, outputs, status, and ordering byte- or semantic-transparently on same-format routes. Restrict normalization to Codex-internal records or explicit protocol conversion.", "Add bounded excessive_tool_loop classification without taking global ownership of external-client tool loops, retries, terminals, or fallback policy.", "Implementation may run in parallel with Issue #190. Squash merge remains blocked on Issue #190; after that merge, update the branch to dev and regenerate every final-SHA check, review, Debug build, and twelve-round evidence." ], "difficulty": "heavy", "done_when": [ "python -m pytest -q tests/test_routing.py tests/test_chat_completions_gateway.py", "python -m pytest -q", "git diff --check", "python scripts/report_quality_gates.py (report-only)", "Exact-SHA GitHub Actions and strict heavy review pass after final dev refresh", "Authoritative machine-bound host twelve-round matrix is all green on the same final SHA after Issue #190 merges" ], "priority": "P1", "risk": "strict", "sha256": "1ff14dbee06ecd94fb43a834b557450b186b62b69343c35bf0718549dbf1e46f", "unresolved_decisions": [] }, "dispatch": { "attempt": 1, "base_sha": "e424f659d158a0a71bb60061f56487051fc3e346", "branch": "work/issue-193", "claimed_at": "2026-07-22T15:35:40.681528Z", "contract_sha256": "1ff14dbee06ecd94fb43a834b557450b186b62b69343c35bf0718549dbf1e46f", "creator_agent_id": "fc91861e-6478-4d4e-8019-d7d0cff5c451", "generation": 1, "id": "dispatch-issue-193-a1", "status": "running", "worker_agent_id": "17fdf2ea-2227-4a37-bcf9-3bbf32ed53b8", "workspace_id": "wks_257846746b055857" } }2 remaining items
fix(gateway): bound transparent chat tool loops (#193)
fix(gateway): stop repeated transparent Chat tool loops (#204)
NOirBRight commentedon Jul 25, 2026
Phase 0 frontier reconciliation complete.
devasb58fbeffb6726e04780ddac8d969897f0ff3610d; that merge is an ancestor of currentdev.69b71bd5876207909c12cc560bf1279c61e2995fhas 7/7 exact-SHA Actions success and native heavy COMMENTED review4757497001with embeddedverdict=pass,findings=[].No additional code change is required for this ticket. Closing it unlocks the bounded #18 implementation slices beginning with #221.