Repository navigation
Conversation
- use part.functionCall.id when provided by Gemini models - generate unique identifier fallbacks when tool call IDs are omitted - remove per-request counter state that caused duplicate tool_0 IDs Signed-off-by: Major Hayden <[email protected]>
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
- avoid keying process-global jobs with model-supplied tool call IDs - pass unique job ID to notifyWhenDone while retaining model-visible ID in XML - test that shell calls do not collide with running background jobs sharing the same tool call ID Signed-off-by: Major Hayden <[email protected]>
fc8c4e3 to
8f58c11
Compare
# Conflicts: # packages/ai/src/protocols/gemini.ts # packages/ai/test/provider/gemini.test.ts # packages/core/src/tool/plugin/shell.ts
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #43940
Type of change
What does this PR do?
Foreground
shelltool calls can hang forever when Gemini models are used. The command runs to completion and its output is fully written, but the tool never settles because:gemini.tsresets its tool call ID counter per request, assigningtool_0to the first tool call of every request and ignoringpart.functionCall.idwhen provided by the API.packages/core/src/tool/plugin/shell.tskeyed process-global jobs by the raw tool call ID (context.id), causingjob.startto treat subsequent calls with identical IDs as job joins and skip forking the new command handler if an unsettled job with that ID was running.shell.tsthen awaitedruntime.job.block, which deadlocked on the stale job's deferreds.This PR fixes both layers:
packages/ai/src/protocols/gemini.ts, usespart.functionCall.idwhen present and generates a unique identifier fallback using@opencode-ai/schema/identifierwhen omitted, removing the per-requestnextToolCallIdcounter state.packages/core/src/tool/plugin/shell.ts, decouples process-global jobs from raw model-provided tool call IDs by omittingidinjob.start(allowingjob.tsto allocate a unique ID) and passingjob.idtonotifyWhenDonewhile keepingcontext.idfor model-facing synthetic session XML and metadata.How did you verify your code works?
packages/ai/test/provider/gemini.test.tsverifying thatfunctionCall.idis preserved, fallback IDs are unique across multiple calls and separate requests, and tool continuation requests match.packages/core/test/tool-shell.test.tsverifying that multiple shell tool calls sharing the same tool call ID execute without collision.packages/aiandpackages/core.Screenshots / recordings
N/A (backend execution engine fix)
Checklist