Skip to content

fix(ai): isolate Gemini function-response turns - #43479

Open
major wants to merge 1 commit into
anomalyco:v2from
major:vertex-tool-continuation
Open

fix(ai): isolate Gemini function-response turns#43479
major wants to merge 1 commit into
anomalyco:v2from
major:vertex-tool-continuation

Conversation

@major

@major major commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Refs #43478

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Prevents Gemini system updates from being merged into the user turn containing a function response.
Gemini requires that function-response turn to contain only the function response when continuing after a tool call.
Updates after a function response now start a separate user turn, while consecutive updates continue to coalesce.

How did you verify your code works?

  • bun test test/provider/gemini.test.ts from packages/ai
  • bun typecheck from packages/ai

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@major
major marked this pull request as draft August 19, 2026 16:48
@major

major commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Anthropic message change is too broad... converting to draft to fix it up

@major
major force-pushed the vertex-tool-continuation branch from ecfec6b to 0827266 Compare August 19, 2026 17:01
@major major changed the title fix(ai): preserve Vertex tool continuations fix(ai): isolate Gemini function-response turns Aug 19, 2026
@major
major marked this pull request as ready for review August 19, 2026 17:03
- keep chronological system updates out of the Gemini turn that answers a function call

- cover repeated updates following a tool result

Refs anomalyco#43478

Signed-off-by: Major Hayden <major@mhtx.net>
@major
major force-pushed the vertex-tool-continuation branch from 0827266 to 980ea4a Compare August 19, 2026 22:24
@major

major commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Good method for testing:

opencode2 run --standalone --model 'google-vertex/gemini-3.7-flash' --format json 'Use your available tools to fetch current NVDA daily closing-price data and calculate its 20-trading-day simple moving average. You must make at least one tool call before answering. Report the SMA, data source, and the latest included trading date.'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant