Skip to content

Conversation

@ndoschek
Copy link
Member

@ndoschek ndoschek commented Nov 26, 2025

What it does

Resolves GH-16640

Update @google/genai dependency to 1.30.0

Following the @google/genai 1.30.0 SDK update, this commit adds proper support for Gemini's thinking feature and improves response handling.

  • Enable thinking mode via thinkingConfig.includeThoughts for streaming
  • Preserve thoughtSignature when converting tool calls to maintain conversation context across tool use cycles
  • Extract text content from response parts instead of using chunk.text to correctly distinguish between thinking and regular content
  • Fix functionResponse format to match Gemini API requirements name + response object, without id field)
  • Add data field to ToolCall/ToolCallChatResponseContent for passing provider-specific metadata like thoughtSignature
  • Handle MALFORMED_FUNCTION_CALL as warning instead of error
  • Wrap non-object tool results in { result: ... } for Gemini compliance

How to test

  • I tested with gemini 2.5-pro and gemini 3; gemini 3 performing better in my tests
    • slow performance from time to time for both of the models
  • I did small coder requests like asking Coder to rename a variable and also longer requests like Jonas' request to add a reset token button.

Follow-ups

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Review checklist

Reminder for reviewers

@github-project-automation github-project-automation bot moved this to Waiting on reviewers in PR Backlog Nov 26, 2025
@JonasHelming
Copy link
Contributor

I did not get the above mentioned errors anymore, but it hangs for longer runs.

Longer runs

I get these warnings:

2025-11-26T22:39:02.138Z root WARN there are non-text parts functionCall in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.

2025-11-26T22:38:56.893Z root WARN there are non-text parts functionCall,thoughtSignature in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.

Test case for long runs: "Add a button to my token usage view to reset the token count"

Short runs

First message works, but on the second I get:
{"error":{"message":"{\n "error": {\n "code": 400,\n "message": "Function call is missing a thought_signature in functionCall parts. This is required for tools to work correctly, and missing thought_signature may lead to degraded model performance. Additional data, function call default_api:getWorkspaceFileList , position 2. Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for more details.",\n "status": "INVALID_ARGUMENT"\n }\n}\n","code":400,"status":"Bad Request"}}

Test case for short runs:

  1. Add a new line to my readme "fooba"
  2. Translate the readme to spanish (fails)

@ndoschek
Copy link
Member Author

Hi again @JonasHelming, thanks for testing the first attempt!
I've now added a few more changes and did some additional testing myself. It already works much better now (tested with Gemini 2.5-Pro and 3-Pro-Preview) for both shorter and longer runs.
Still, it would be great if you could test it again as well.

In general, the Gemini models feel slower to me compared to others, but I haven't used them very often in the past, so I don’t have a solid basis for comparison.
Also, I would appreciate it if you could take a look at the code too if it seems reasonable to you.

@JonasHelming
Copy link
Contributor

I will test this afternoon.

First try got the error below (which might be unrelated to us)

{"error":{"message":"{\n "error": {\n "code": 500,\n "message": "An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting\",\n "status": "INTERNAL"\n }\n}\n","code":500,"status":"Internal Server Error"}}

@JonasHelming
Copy link
Contributor

JonasHelming commented Nov 27, 2025

@coder add a button to the token usage view to reset the token count

With this prompt it still hangs and then I get the two warnings in the console:

Please refer to the non text parts for a full response from model.
2025-11-27T11:14:22.962Z root WARN there are non-text parts functionCall,thoughtSignature in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.
2025-11-27T11:14:23.321Z root WARN there are non-text parts functionCall in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.

I also have the feeling it takes very long, maybe it retries or thinks too much?

The simple "@coder Add a new lint to the readme "fooba"

  1. ran into an endless loop for me
  2. Works sometimes
  3. Adds the line 3 times and then removes it again

I somehow have the feeling that there is smething wrong with the tool response, for example this would explain why it applies the change three times (it does not get feedback)?

@ndoschek ndoschek changed the title attempt to fix gemini model response part update @google/genai dependency and add thoughtSignature support Nov 27, 2025
@ndoschek ndoschek marked this pull request as ready for review November 27, 2025 14:37
@ndoschek
Copy link
Member Author

Review request was opened and already approved for the updated dependency:

[main] INFO A review request was created https://gitlab.eclipse.org/eclipsefdn/emo-team/iplab/-/issues/25016 .

@sdirix
Copy link
Member

sdirix commented Nov 28, 2025

I have the same issue as @JonasHelming. When I send a non-trivial request to Gemini 3 with @Coder, it's basically non-functional: It will perform some tool calls but then just stop responding after a while with these warnings in the console

WARN there are non-text parts functionCall,thoughtSignature in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.
WARN there are non-text parts functionCall,thoughtSignature in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.
WARN there are non-text parts functionCall,thoughtSignature in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.
WARN there are non-text parts functionCall,thoughtSignature in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.
WARN there are non-text parts functionCall,thoughtSignature in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.
WARN there are non-text parts functionCall in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.
WARN there are non-text parts functionCall in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.
WARN there are non-text parts functionCall in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.
WARN there are non-text parts functionCall,thoughtSignature in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.
WARN there are non-text parts functionCall in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.
WARN there are non-text parts functionCall in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.

When using Gemini 2, I easily run into errors like this:

ERROR Error handling chat interaction: Error: Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them
    at tContents (/home/user/git/theia/examples/browser/lib/backend/vendors-node_modules_drivelist_build_Release_drivelist_node-dev-packages_application-package_-79e056.js:10101:19)
    at generateContentParametersToMldev (/home/user/git/theia/examples/browser/lib/backend/vendors-node_modules_drivelist_build_Release_drivelist_node-dev-packages_application-package_-79e056.js:16173:31)
    at Models.generateContentStreamInternal (/home/user/git/theia/examples/browser/lib/backend/vendors-node_modules_drivelist_build_Release_drivelist_node-dev-packages_application-package_-79e056.js:20326:26)
    at Models.generateContentStream (/home/user/git/theia/examples/browser/lib/backend/vendors-node_modules_drivelist_build_Release_drivelist_node-dev-packages_application-package_-79e056.js:19854:35)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async GoogleModel.withRetry (/home/user/git/theia/examples/browser/lib/backend/main.js:7609:24)
    at async GoogleModel.handleStreamingRequest (/home/user/git/theia/examples/browser/lib/backend/main.js:7373:24)
    at async [Symbol.asyncIterator] (/home/user/git/theia/examples/browser/lib/backend/main.js:7519:51)
    at async [Symbol.asyncIterator] (/home/user/git/theia/examples/browser/lib/backend/main.js:7521:42)
    at async /home/user/git/theia/examples/browser/lib/backend/main.js:6954:34

So sadly I don't think it really improves on the current state

@ndoschek
Copy link
Member Author

ndoschek commented Nov 28, 2025

Thanks for testing!
This is really weird that it works for me then, I never saw the mentioned errors during my testing.
I had another look what might be different and I used the default coder prompt variant (coder-system-edit) during my tests apparently. With the next variant I now also got such issues.
Which variant did you both use?

@JonasHelming
Copy link
Contributor

JonasHelming commented Nov 28, 2025

Next variant!

But the default on master is now using the next variant, we made the new functions default

@ndoschek
Copy link
Member Author

Ah I see, I didn't reset my variant in my runtime yet, that would explain why it worked for me.
I'll convert this to a draft again then, thanks again for testing!

@ndoschek ndoschek marked this pull request as draft November 28, 2025 11:12
@sdirix
Copy link
Member

sdirix commented Nov 28, 2025

I don't think it's really Coder prompt related. The Gemini 2 models seem rather lazy to me. I invoked @Coder with the instruction to generate an implementation plan for a large feature. It then proceeded to not look at the code base once and just executed a single tool call to propose the implementation plan changes. A single tool call usually works fine, so I had to explicitly call it out to produce more tool calls and thereby the errors.

@ndoschek
Copy link
Member Author

What I can observe also: if I change the suggestFileReplacements to simpleSuggestFileReplacements (also different from suggestFileReplacements_Simple) in the coder default prompt it works fine again for me (except for the warning sin the backend, they're still there).
I'll have a look if I can spot something in that area.

@ndoschek
Copy link
Member Author

ndoschek commented Dec 2, 2025

Summary of my findings so far:

I made a small rework to integrate thought summaries (temporarily), merge part text fields, and enable thought summaries for more insights. Also with this changes the warnings about Mixing Content and Parts is not supported are gone now. Also I removed most of the previous changes again.

I'm still running into several issues with my Gemini model implementation:

  • Short tasks work mostly fine (like adding a new line to a README), but it’s still a bit slow.

  • Changing suggestFileReplacements to simpleSuggestFileReplacements (which is different from suggestFileReplacements_Simple) affected the behavior with the previous state of my changes, although with my latest changes there seems to be no difference anymore.

  • Follow-ups to tasks are not working well at all: the model repeats too many steps and needs a long time to complete. The thinking summaries in the logs show this clearly. I'm not sure whether to double-check or adjust the function call parts based on Google’s function-calling documentation (see https://ai.google.dev/gemini-api/docs/function-calling?example=meeting, https://ai.google.dev/gemini-api/docs/thought-signatures#function-calling)

  • Currently thought signatures are not handled explicitely, and I’m unsure whether we need to. The documentation says "Note: If you use the official Google Gen AI SDKs and use the chat feature (or append the full model response object directly to history), thought signatures are handled automatically. You do not need to manually extract or manage them, or change your code." (https://ai.google.dev/gemini-api/docs/thought-signatures), but not sure if this is the case for us.

  • Retries on error runs always fail with an error saying that the function call is missing a thought signature:

    • Function call is missing a thought_signature in functionCall parts… may lead to degraded model performance.
    • This happens consistently, so I suspect that I'm missing some kind of reset or reinitialization before retrying.

@eneufeld @sdirix
Could you have a look please as well if you can spot anything either in the implementation and/or the documentation? TIA

PS: @JonasHelming I think there is no immediate need to retest now, we can ping you again if there is more progress.

@ndoschek ndoschek changed the title update @google/genai dependency and add thoughtSignature support update @google/genai dependency, add thoughtSignature support and fix content extraction Dec 3, 2025
@ndoschek ndoschek requested a review from eneufeld December 3, 2025 14:53
@ndoschek ndoschek marked this pull request as ready for review December 3, 2025 14:54
@ndoschek
Copy link
Member Author

ndoschek commented Dec 3, 2025

Hi again,
together we could fix out a few problems due to updates in the genai API.
It now worked fine for me with the mentioned test runs in the PR description.

@eneufeld, @JonasHelming, @sdirix
Would be great if you could do a test run and give some feedback, TIA!

Copy link
Contributor

@eneufeld eneufeld left a comment

Choose a reason for hiding this comment

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

Change looks good to me. I tested it with TheiaDev and TheiaDevCoder. This worked fine.

@github-project-automation github-project-automation bot moved this from Waiting on reviewers to Needs merge in PR Backlog Dec 4, 2025
Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

Works great for me. I left some comments. Feel free to tackle them if you want, but none of them is a blocker for merge.

Comment on lines +203 to +206
thinkingConfig: {
// https://ai.google.dev/gemini-api/docs/thinking#summaries
includeThoughts: true,
},
Copy link
Member

Choose a reason for hiding this comment

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

Do we set thinking on "on" on purpose? It's a bit cumbersome to turn it off again

"ai-features.modelSettings.requestSettings": [
  {
    "scope": {
      "providerId": "google"
    },
    "requestSettings": {
      "thinkingConfig": {
        "includeThoughts": false
      }
    }
  }
]

On the other hand, turning it on would be equally as difficult, so I am fine either way

Copy link
Member Author

@ndoschek ndoschek Dec 9, 2025

Choose a reason for hiding this comment

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

Yes, I mainly added it to get to know the model better, but I agree it might not be for everyone. I'll create a follow-up to make it configurable via the UI (see GH-16642)

Resolves GH-16640

Following the @google/genai 1.30.0 SDK update, this commit adds proper support for Gemini's thinking feature and improves response handling.

- Enable thinking mode via thinkingConfig.includeThoughts for streaming
- Preserve thoughtSignature when converting tool calls to maintain conversation context across tool use cycles
- Extract text content from response parts instead of using chunk.text to correctly distinguish between thinking and regular content
- Fix functionResponse format to match Gemini API requirements name + response object, without id field)
- Add data field to ToolCall/ToolCallChatResponseContent for passing provider-specific metadata like thoughtSignature
- Handle MALFORMED_FUNCTION_CALL as warning instead of error
- Wrap non-object tool results in { result: ... } for Gemini compliance
@ndoschek
Copy link
Member Author

ndoschek commented Dec 9, 2025

Thanks for the reviews!
@sdirix I addressed most of your comments, for the thinking config I will create a follow up and keep it on for now.

@ndoschek ndoschek merged commit 6083c78 into master Dec 9, 2025
11 checks passed
@github-project-automation github-project-automation bot moved this from Needs merge to Done in PR Backlog Dec 9, 2025
@ndoschek ndoschek deleted the GH-16640 branch December 9, 2025 18:39
@github-actions github-actions bot added this to the 1.67.0 milestone Dec 9, 2025
import { GoogleGenAI, FunctionCallingConfigMode, FunctionDeclaration, Content, Schema, Part, Modality, FunctionResponse, ToolConfig } from '@google/genai';
import { wait } from '@theia/core/lib/common/promise-util';
import { GoogleLanguageModelRetrySettings } from './google-language-models-manager-impl';
import { UUID } from '@theia/core/shared/@lumino/coreutils';
Copy link
Member

Choose a reason for hiding this comment

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

I meant generateUuid from @theia/core ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah I see, thanks! I take a note that for the follow up then :)

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

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Gemini models hang, return malformed tool calls, or fail with 503 errors during AI task execution

5 participants