Skip to content

Conversation

@bkvarda
Copy link
Contributor

@bkvarda bkvarda commented Dec 19, 2025

Summary

Various model providers have started including additional fields in in tool_calls of openai-compatible(ish) chatcompletion responses, for example gemini's thought_signature and databricks' thoughtSignature. This change adds an extra Map field in DeltaToolCallFunction to support arbitrary additional fields. Then added inclusion of these additional fields in databricks format_messages which fixes 400: content block is missing a thought_signature errors when trying to use tools w/ gemini-3 in databricks.

Type of Change

  • Feature
  • Bug fix
  • Refactor / Code quality
  • Performance improvement
  • Documentation
  • Tests
  • Security fix
  • Build / Release
  • Other (specify below)

AI Assistance

  • This PR was created or reviewed with AI assistance

Testing

Added unit tests and tested manually with databricks-gemini-3-pro and databricks-gemini-3-flash

Screenshots/Demos (for UX changes)

image

Copilot AI review requested due to automatic review settings December 19, 2025 00:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for arbitrary extra fields in OpenAI-compatible chat completion tool calls to handle provider-specific metadata like Gemini's thought_signature and Databricks' thoughtSignature. This fixes 400 errors when using tools with gemini-3 models through Databricks.

  • Adds an extra field with #[serde(flatten)] to DeltaToolCall to capture non-standard fields
  • Updates message formatting to include metadata fields in outgoing tool call requests
  • Extracts and preserves extra fields from responses in both streaming and non-streaming paths

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
crates/goose/src/providers/openai.rs Reorganizes imports (moved to top of file)
crates/goose/src/providers/formats/openai.rs Adds extra field to DeltaToolCall, updates format_messages to include metadata in tool calls, extracts extra fields in response_to_message and streaming handler, adds comprehensive tests
crates/goose/src/providers/formats/databricks.rs Updates format_messages to include metadata in tool calls (mirrors OpenAI changes), adds tests for metadata handling

@bkvarda bkvarda force-pushed the bkvarda/gemini3-openai-compat branch from f7c815b to e66647c Compare December 19, 2025 00:29
@bkvarda bkvarda requested a review from a team as a code owner December 19, 2025 00:29
Copilot AI review requested due to automatic review settings December 19, 2025 16:39
@bkvarda bkvarda force-pushed the bkvarda/gemini3-openai-compat branch from e66647c to c4586c6 Compare December 19, 2025 16:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@DOsinga
Copy link
Collaborator

DOsinga commented Dec 19, 2025

we just merged: #6035 which does something similar - can you check whether that covers your intentions? it feels like it is doing both more (handling the thought signatures) and also less (doesn't store all meta information)

@bkvarda
Copy link
Contributor Author

bkvarda commented Dec 22, 2025

@DOsinga I tried with #6035 but it didn't seem to resolve scenarios in which the goose provider is parsing responses as OpenAI-compatible responses using stream_openai_compat which call the oai response_to_streaming_message (like the databricks provider does, but a number of others look like they do such as openrouter and xai).

brandon.kvarda@HQ2MPQV7RY goose % git checkout fc8a4b4adfbd771c09d867c0a5c04d643f83905a
HEAD is now at fc8a4b4adf fix(google): Fix 400 Bad Request error with Gemini 3 thought signatures (#6035)
brandon.kvarda@HQ2MPQV7RY goose % cargo build
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.08s
brandon.kvarda@HQ2MPQV7RY goose % GOOSE_MODEL=databricks-gemini-3-pro DATABRICKS_HOST=https://e2-demo-field-eng.cloud.databricks.com ./target/debug/goose
starting session | provider: databricks model: databricks-gemini-3-pro
    session id: 20251222_14
    working directory: /Users/brandon.kvarda/othercode/goose

goose is running! Enter your instructions, or try asking what goose can do.

Context: ○○○○○○○○○○ 0% (0/128000 tokens)
( O)> read a file in this dir

─── read_module | code_execution ──────────────────────────
module_path: developer

Ran into this error: Request failed: Bad request (400): {
  "error": {
    "code": 400,
    "message": "Unable to submit request because function call `default_api:code_execution__read_module` in the 2. content block is missing a `thought_signature`. Learn more: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures",
    "status": "INVALID_ARGUMENT"
  }
}
.

Please retry if you think this is a transient or recoverable error.

⏱️  Elapsed time: 5.31s

@spazbg
Copy link

spazbg commented Dec 30, 2025

I can validate that in the latest release 1.18.0 this issue is still present, so please share a fix ASAP. We want to use this dirt cheap and fast Gemini 3 flash model :)

Brandon Kvarda and others added 2 commits January 6, 2026 12:48
…tc.)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Brandon Kvarda <brandon.kvarda@databricks.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Brandon Kvarda <brandon.kvarda@databricks.com>
@bkvarda bkvarda force-pushed the bkvarda/gemini3-openai-compat branch from c4586c6 to 7f0d13b Compare January 6, 2026 20:54
@bkvarda
Copy link
Contributor Author

bkvarda commented Jan 6, 2026

@spazbg which provider are you using? if not databricks any chance you could build goose cli from this and validate if it works for your provider as well? EDIT: Also you might have to do something like this in the specific provider also.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants