GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(command-code): pair tool results and synthesize missing-result errors by Wibias · Pull Request #1411 · lidge-jun/opencodex

Conversation

@Wibias

@Wibias Wibias commented Aug 10, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

  • Command Code (/alpha/generate) rejects any assistant tool call that has no matching tool result on the continuation, surfacing as a generic 502 (Tool result is missing for tool call <id>). The adapter now keeps that pairing invariant before sending: every declared call is closed by a result, and orphan results degrade to text carriers.
  • Tool results that match a declared assistant call keep the native tool-result wire shape (unchanged); unpaired calls get an explicit error-text result so the upstream never fails the whole turn.
  • The upstream missing-tool-result error is now classified distinctly (errorType: upstream_error, code: missing_tool_result) so the dashboard/logs distinguish provider-side tool-result validation from generic stream failures.

Validation

  • bun test tests/command-code-provider.test.ts — pass (26 tests, incl. new pairing, orphan-carrier, and classification coverage)
  • bun run typecheck — pass
  • bun run privacy:scan — pass
  • Pre-open gate (pre-open-gate.mjs) — ready; bug + security lenses and required probes verified
  • Full bun run test — not fully green on this machine; failures reproduced identically on the base tip (2036ed734) in unrelated subsystems (catalog writer, codex-auth WHAM, restore/journal) and are pre-existing Windows/Bun environment issues, not caused by this change

Review notes

  • The pairing logic mirrors the Anthropic adapter's solved Anthropic 400: tool_use ids found without tool_result blocks (messagesToAnthropicFormat) #620 pattern: results pair to declared calls, missing results are synthesized as errors, and orphans carry as text.

Fixes #1383

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of assistant tool calls and their results during command processing.
    • Converts unmatched tool results into readable user content.
    • Reports unresolved tool calls with explicit error results instead of leaving requests incomplete.
    • Preserves images included in tool results.
    • Provides clearer error details when upstream responses omit required tool results.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Wibias
fix(command-code): pair tool results and synthesize missing-result er…
aca2752
…rors

The /alpha/generate wire requires every assistant tool-call to be closed
by a matching tool-result. Codex history can leave a call unpaired
(interrupted turns, compaction, multi-step rounds), and the upstream
rejects that with 'Tool result is missing for tool call <id>', surfacing
as a generic 502 (#1383).

- Track declared assistant tool-call ids and pair tool results to them.
- Close every declared call that never received a result with an explicit
  error-text tool-result before the next non-tool message.
- Degrade orphan tool results (no declared call) to a user text carrier
  instead of a 400-prone standalone tool message.
- Classify the upstream missing-tool-result error distinctly
  (errorType upstream_error, code missing_tool_result).
@Wibias
Wibias requested review from Ingwannu and lidge-jun as code owners August 10, 2026 07:47
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the bug Something isn't working label Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8d6568a8-fd09-498e-8c0b-857d028ee6ab

📥 Commits

Reviewing files that changed from the base of the PR and between aca2752 and fc1c729.

📒 Files selected for processing (2)
  • src/adapters/command-code.ts
  • tests/command-code-provider.test.ts

📝 Walkthrough

Walkthrough

wireMessages now preserves assistant tool-call/result pairing, synthesizes results for unresolved calls, converts orphan results to user text, buffers images, and classifies upstream missing-tool-result stream errors with dedicated metadata.

Changes

Command Code tool-result handling

Layer / File(s) Summary
Tool-call and result wiring
src/adapters/command-code.ts, tests/command-code-provider.test.ts
The adapter pairs results by call ID, buffers tool-result images, converts orphan results to user text, and synthesizes error results before later messages or completion. Tests cover these cases and preserve contiguous tool results.
Missing-tool-result stream classification
src/adapters/command-code.ts, tests/command-code-provider.test.ts
The adapter recognizes spaced and underscored missing-tool-result errors and emits errorType: "upstream_error" with code: "missing_tool_result". Other errors retain the generic 502 response shape. Tests verify the terminal done event.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant CommandCodeAdapter
  participant wireMessages
  participant CommandCodeProvider
  Client->>CommandCodeAdapter: submit conversation
  CommandCodeAdapter->>wireMessages: serialize tool calls and results
  wireMessages-->>CommandCodeAdapter: paired or synthesized tool results
  CommandCodeAdapter->>CommandCodeProvider: send continuation
  CommandCodeProvider-->>CommandCodeAdapter: stream response or missing-tool-result error
  CommandCodeAdapter-->>Client: response or classified stream error
Loading

Possibly related PRs

  • lidge-jun/opencodex#1066: Modifies the same Command Code adapter and tests for related tool-call/result pairing and stream error handling.

Suggested reviewers: ingwannu, lidge-jun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: pairing tool results and synthesizing errors for missing results.
Linked Issues check ✅ Passed The changes address issue #1383 by pairing tool results, synthesizing missing-result errors, preserving images, and classifying upstream validation failures.
Out of Scope Changes check ✅ Passed All changes support issue #1383, including image buffering needed to preserve tool-result adjacency and targeted regression tests.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ocx-120-provider-compatibility-command-code-returns-502

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias Wibias mentioned this pull request Aug 10, 2026
[Provider compatibility] Command Code returns 502 upstream_server_error: "Tool result is missing for tool call" #1383
Closed
3 tasks done
coderabbitai[bot]
coderabbitai Bot reviewed Aug 10, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/adapters/command-code.ts`:
- Around line 99-112: Update the image-carrier handling in
src/adapters/command-code.ts around lines 99-112 to buffer user image carriers
while pendingCalls is non-empty, flushing them only after every
assistant-declared call has a native or synthesized tool result so tool results
remain contiguous. Add the two-call image-first scenario in
tests/command-code-provider.test.ts around lines 165-183 and assert both
tool-result messages precede the user image carrier.

In `@tests/command-code-provider.test.ts`:
- Around line 360-372: Extend the missing-tool-result coverage in the test using
createCommandCodeAdapter and isMissingToolResultError by adding an upstream
error message containing “tool_result is missing” instead of the spaced variant.
Assert that parsing produces the same errorType “upstream_error” and code
“missing_tool_result” while preserving the existing response behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8e72932b-8a05-4368-980c-e969d2ff3856

📥 Commits

Reviewing files that changed from the base of the PR and between 4f32280 and aca2752.

📒 Files selected for processing (2)
  • src/adapters/command-code.ts
  • tests/command-code-provider.test.ts

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/adapters/command-code.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/command-code-provider.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Wibias
fix(command-code): buffer image carriers until tool results close
fc1c729
CodeRabbit flagged that a paired tool result carrying an image emitted its
user image carrier immediately, breaking the adjacency of remaining pending
tool results on the /alpha/generate wire (assistant -> tool(call_1) -> user
image -> tool(call_2)).

Buffer image carriers while any declared call is still pending and flush
them only after every call has its native or synthesized result. Also add
the underscored tool_result is missing classification test.
@Wibias
Wibias merged commit 0de4fd2 into dev Aug 10, 2026
27 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Wibias
Wibias deleted the ocx-120-provider-compatibility-command-code-returns-502 branch August 10, 2026 08:02
This was referenced Aug 15, 2026
[Bug] Gemini/Antigravity tool call loses thoughtSignature during Codex continuation #1735
Closed
[Bug]: sensenova hallucinates undeclared exec tool in subagent requests causing 502 stream disconnected #1795
Closed
@coderabbitai coderabbitai Bot mentioned this pull request Sep 12, 2026
feat(providers): ZCode — Z.ai Start Plan provider (OAuth login, traceless captcha, client attribution) #4437
Closed
4 tasks
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
@Wibias
Merge pull request lidge-jun#1411 from lidge-jun/ocx-120-provider-com…
8340716
…patibility-command-code-returns-502

fix(command-code): pair tool results and synthesize missing-result errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments
@lidge-jun lidge-jun Awaiting requested review from lidge-jun lidge-jun is a code owner
@Ingwannu Ingwannu Awaiting requested review from Ingwannu Ingwannu is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

bug Something isn't working

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Wibias
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.