Repository navigation
fix(core): replay hosted tool results across providers - #57045
abigfatstone wants to merge 1 commit into
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
The fix looks correct and is in the right place. The new regression test fails on the base with the OpenAI Chat compile error from #57044 and passes with this PR. The three core suites pass (47 tests) and the packages/core type check is clean. I couldn't run it end to end because there was no provider that runs tools itself.
Public API: unchanged. The change only affects how stored session history is turned into request messages; stored messages are not changed.
One concern, inline: the fix only applies when the provider changes. A model switch within one provider whose models use different protocols probably still fails the same way.
| // A different provider needs ordinary tool messages, not the original provider's | ||
| // inline hosted results. Normalize only this replay, preserving stored history. | ||
| const parts = message.content.map((item) => | ||
| item.type === "tool" && item.executed === true && !sameProvider ? { ...item, executed: false } : item, |
There was a problem hiding this comment.
This only rewrites provider-executed tools when the provider changes. Some providers send different models through different protocols. GitHub Copilot, for example, sends some models through Responses and others through Chat. Switching between such models keeps sameProvider true, so provider-executed results stay inline and OpenAI Chat should reject them with the same error. I haven't confirmed Copilot can actually record provider-executed tools, but nothing here guards against it. Could the condition be based on whether the target model can replay the call natively (same model, or at least same protocol) instead of on the provider ID? If the provider check is intentional, could you say so in the comment so the limitation is known?
Issue for this PR
Closes #57044
Type of change
What does this PR do?
When replaying an assistant message against a different provider, treat its provider-executed tools as ordinary calls with separate tool results. OpenAI Chat can then compile the history instead of rejecting inline tool-result parts.
Normalization only affects request history. Stored messages and same-provider native replay stay unchanged.
How did you verify your code works?
The new regression failed before the fix with the reported OpenAI Chat compilation error. After the fix, core session-runner-message, session-model-request and session-provider-context tests pass: 47 tests. The message suite also passed 10 repetitions. Covers successful and failed results, mixed local/hosted tools, metadata stripping and switching back without history mutation.
Formatting and changed-file lint passed. Full repository check is not green locally: the sparse checkout lacks development dependencies including drizzle-kit; full typecheck was blocked by missing modules. No live provider call or packaged runtime test.
Screenshots / recordings
No UI changes.
Checklist
Added by the opencode bot (AI-generated).
Related: #53633, #55271