Repository navigation
Let a reasoning model behind OPENAI_BASE_URL answer after its first tool call - #91
Open
chingizmamedov wants to merge 1 commit into
Open
chingizmamedov wants to merge 1 commit into
chingizmamedov wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…ool call With OPENAI_BASE_URL set, a built-in Bot on a reasoning model (Gemma 4 on Ollama, for one) called its first tool and then failed the turn with "unknown input item type: item_reference". The AI SDK's Responses provider defaults to store: true and sends the earlier step's reasoning back as an item_reference to a stored response, which an endpoint other than OpenAI does not keep. The built-in Bot now passes providerOptions.openai.store = false when OPENAI_BASE_URL is set, so each earlier item is sent in full. Without OPENAI_BASE_URL nothing changes.
chingizmamedov
force-pushed
the
fix/compatible-endpoint-store-false
branch
from
October 28, 2026 19:31
2af1741 to
adacc2a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this changes
With
OPENAI_BASE_URLpointing at an OpenAI-compatible endpoint, a built-in Bot on a model that reasons before it answers calls its first tool and then fails the turn:I hit this running OpenDuet's own Bot on a local model: Ollama 0.32.4 serving
gemma4:26b-mlx, configured as.env.exampledescribes (OPENAI_BASE_URL=http://localhost:11434/v1,BOT_MODEL=gemma4:26b-mlx).builtInAgentConfigurationhands the runtime anopenai/<model>string.resolveModelturns that intocreateOpenAI({ baseURL: OPENAI_BASE_URL })(model), which uses the Responses API withstoreleft at its default oftrue. On the second step the AI SDK then sends the first step's reasoning back as{ type: "item_reference", id }, a pointer to a response it expects the server to have stored. OpenAI keeps that response; an endpoint like Ollama keeps nothing and refuses the request. Models that don't reason are unaffected, because nothing is referenced.The fix passes
providerOptions: { openai: { store: false } }when the built-in Bot's provider is OpenAI andOPENAI_BASE_URLis set, so the SDK sends each earlier item in full. It checks the same variableresolveModelreads to choose the endpoint, at the same moment. A plan model (a model sign-in) is left alone. WithoutOPENAI_BASE_URL, the configuration is exactly what it was: the existingconfigures an OpenAI built-in agenttest still passes withtoEqual.Trade-off. On a gateway that fronts OpenAI itself, responses are no longer stored. With
store: false, the AI SDK also drops reasoning that has no encrypted content, so a reasoning model's thinking isn't carried from one step of a turn to the next. Asking forinclude: ["reasoning.encrypted_content"]as well would keep it, and Ollama accepts that field. I left it out because I believe OpenAI rejects it for models that don't reason, which would break those behind a gateway. Happy to add it if that belief is wrong, or to gate this behind an explicit setting if you'd rather not change the default for gateways.Where it belongs. The change is in OpenBot's platform code under
openbot/, and the same lines exist on CopilotKit/openbotmain. I'm happy to open the same change there instead, or as well, if that's where you'd like platform fixes to land first. I leftopenbot/CHANGELOG.mdalone, since OpenDuet's PRs don't edit it; the OpenBot version of this PR would add a line underUnreleased.Changes
openbot/server/src/copilot.ts: thestore: falseoption, 11 lines.openbot/server/tests/copilot.test.ts: a regression test, described below.openbot/docs/configuration.md: one paragraph under "OpenAI-compatible endpoints" on what a compatible endpoint is sent.Where it runs
Proof
Regression test ("a compatible endpoint is sent the earlier step in full, not by reference"). It runs a built-in Bot against aimock, with a fixture that reasons and then calls a tool. A small proxy captures the raw Responses request bodies, because aimock's journal keeps a normalised copy without
storeorinput. The test asserts that both requests carrystore: falseand that the second request'sinputhas noitem_reference. Without the fix, thestoreassertion fails, and so does theitem_referenceassertion on its own.Checks (on this branch, in
openbot/):bun testpasses 93 tests acrosscopilot,task-skill-promptandmodel-providers.bun run format:check,lint,typecheckandtypecheck:testspass.bun run typecheckinserver/passes.By hand (same Ollama setup):
AI_APICallError: input[2]: unknown input item type: "item_reference"That run uses the AI SDK path the built-in Bot takes:
createOpenAI(...)(model),streamText, one tool, three steps. In a running OpenDuet on the same model, a Chat turn that called the morning-brief tool now answers after the tool result.