Conversation
Resolve opaque tool call IDs back to their original function names when rebuilding Gemini history. Refs AstrBotDevs#9876
Add regression coverage for opaque tool call IDs and preserve explicit or legacy function-name fallbacks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 摘要
Resolve opaque Gemini
tool_call_idvalues back to their original function names when rebuilding conversation history.Preserve explicit
namefields and the existing legacy fallback behavior.Add regression tests for opaque IDs and both fallback paths.
在重建 Gemini 对话历史时,将不透明的
tool_call_id正确映射回原始函数名。保留显式
name字段及现有的旧格式回退行为。为不透明 ID 和两条回退路径补充回归测试。
Problem / 问题
Gemini requires
functionResponse.nameto match the precedingfunctionCall.name. Existing history often stores only an opaque ID such ascall_xxx, causing rebuilt requests to fail with HTTP 400.Gemini 要求
functionResponse.name与前面的functionCall.name一致。现有历史记录通常只保存call_xxx形式的不透明 ID,导致重建后的请求因名称不匹配而返回 HTTP 400。Testing / 测试
uv run ruff check astrbot/core/provider/sources/gemini_source.py tests/test_gemini_source.pyuv run ruff format --check astrbot/core/provider/sources/gemini_source.py tests/test_gemini_source.pyuv run pytest -q tests/test_gemini_source.py— 15 passedFixes #9876
Summary by Sourcery
Preserve Gemini function names when rebuilding tool responses so reconstructed conversations remain valid.
Bug Fixes:
Tests: