Skip to content

Conversation

samiulsami
Copy link
Contributor

@samiulsami samiulsami commented Aug 14, 2025

Describe your changes

The issue was apparently that the go-genai module expects the roles in the chat history to be either "user" or "model". Since the tool calls in the history were assigned the role "function", combined with the fact that the chat creation errors were being ignored, resulted in this cryptic/weird issue. This pr introduces a workaround by attributing the tool-call's output to the model.

Steps to validate the fix:

  • make the llm perform any tool call.
  • the main branch panics, while this branch does not.

PS: I'm not sure if this is a "proper fix", since the tool call results shouldn't most likely be attributed to the model in the history.

Related issue/discussion: #768, #771

Checklist before requesting a review

If this is a feature

  • I have created a discussion
  • A project maintainer has approved this feature request. Link to comment:

… calls

Signed-off-by: sami <sami@appscode.com>
@charmcli
Copy link
Contributor

charmcli commented Aug 14, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@samiulsami
Copy link
Contributor Author

I have read the Contributor License Agreement (CLA) and hereby sign the CLA.

@samiulsami samiulsami changed the title Fix Gemini tool-calling panic issue. Fix(gemini): tool-calling panic issue Aug 14, 2025
Copy link
Member

@andreynering andreynering left a comment

Choose a reason for hiding this comment

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

Thank you! I tested and confirmed that the fix works.

@andreynering andreynering enabled auto-merge (squash) August 14, 2025 17:26
@caarlos0 caarlos0 changed the title Fix(gemini): tool-calling panic issue fix(gemini): tool-calling panic issue Aug 14, 2025
@andreynering andreynering merged commit 5ff0f32 into charmbracelet:main Aug 14, 2025
11 of 12 checks passed
@samiulsami samiulsami deleted the fix-panic branch August 14, 2025 17:30
scalabl3 pushed a commit to metaphori-ai/crush that referenced this pull request Aug 19, 2025
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.

4 participants