Skip to content

fix(transport): disable synthetic tool results for OpenAI - #61556

Closed
VictorJeon wants to merge 2 commits into
openclaw:mainfrom
VictorJeon:fix/openai-transport-synthetic-results
Closed

VictorJeon wants to merge 2 commits into
openclaw:mainfrom
VictorJeon:fix/openai-transport-synthetic-results

Conversation

@VictorJeon

Copy link
Copy Markdown

Summary

  • disable synthetic orphan toolResult insertion for OpenAI-compatible transports by default
  • keep synthetic toolResult behavior for Anthropic, Google, and Bedrock Converse transports
  • add transport-level regression coverage for both OpenAI and Anthropic behavior

Why

resolveTranscriptPolicy() already disables synthetic tool results for OpenAI-compatible replay, but transformTransportMessages() was still unconditionally inserting synthetic toolResult messages with "No result provided" when an orphan tool call was encountered.

That mismatch could poison OpenAI session history and lead to downstream pairing/replay failures.

This change aligns transport behavior with transcript policy expectations.

Follow-up / companion to #61337.

Validation

  • pnpm exec vitest run --config vitest.config.ts --project agents src/agents/transport-message-transform.test.ts src/agents/transcript-policy.test.ts

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Apr 5, 2026
@greptile-apps

greptile-apps Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Aligns transformTransportMessages with resolveTranscriptPolicy by gating synthetic orphan toolResult insertion behind a new defaultAllowSyntheticToolResults helper that returns true only for anthropic-messages, bedrock-converse-stream, and google-generative-ai — matching existing transcript-policy defaults. The fix prevents poisoned session history for OpenAI-compatible transports; provider-replay-helpers.ts is updated to explicitly set allowSyntheticToolResults: true in the Anthropic and Google replay policy builders, and regression tests cover both the OpenAI suppression and Anthropic retention paths. All three production transport call sites (anthropic-transport-stream.ts, google-transport-stream.ts, openai-transport-stream.ts) pass no options, so they pick up the correct new default automatically.

Confidence Score: 5/5

Safe to merge — the fix is targeted, all three transport call sites inherit the correct new default, and regression tests cover both the OpenAI suppression and Anthropic retention paths.

No P0 or P1 issues found. The new defaultAllowSyntheticToolResults helper correctly gates synthetic results by model API. All existing callers pass no options so they inherit the correct default. buildOpenAICompatibleReplayPolicy correctly omits allowSyntheticToolResults (resolves to false via mergeTranscriptPolicy defaults). Tests use current model constants (gpt-5.4, claude-opus-4-6) per project guidelines.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(transport): disable synthetic tool r..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 31374f7d08

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +3 to +7
function defaultAllowSyntheticToolResults(modelApi: Api): boolean {
return (
modelApi === "anthropic-messages" ||
modelApi === "bedrock-converse-stream" ||
modelApi === "google-generative-ai"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Handle transport alias APIs in synthetic-result default

defaultAllowSyntheticToolResults only recognizes canonical APIs, but transport-aware simple mode rewrites Anthropic/Google models to alias APIs like openclaw-anthropic-messages-transport and openclaw-google-generative-ai-transport (see src/agents/provider-transport-stream.ts). In that path this now evaluates to false, so Anthropic/Google requests stop getting synthetic tool results even though this change intends to keep that behavior for those families, which can leave orphaned tool calls in replay and trigger strict-provider request rejections.

Useful? React with 👍 / 👎.

@vincentkoc

Copy link
Copy Markdown
Member

superseded by #66447.

rebased onto current main, narrowed the replay fix to the supported alias transports, added focused regression coverage, and carried the missing changelog entry.

@vincentkoc vincentkoc closed this Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants