Repository navigation
Conversation
…tory TemplateChatSession.sendMessage only added the user message and final model response to history, dropping the intermediate functionCall and functionResponse turns collected in requestHistory. On a follow-up sendMessage the model no longer saw what its tools returned. The other three paths (sendMessageStream, ChatSession.sendMessage/Stream) already append the whole requestHistory. Align sendMessage with them.
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
Description
Fixes #18757.
TemplateChatSession.sendMessageonly added the original user message and the final model response tohistory, dropping the intermediate turns collected inrequestHistory— the model'sfunctionCallcontent and the function responses produced by auto-executedTemplateAutoFunctionDeclarations. On the nextsendMessagethe model no longer saw what its tools returned (e.g. an id a prior call created), while the other three paths (sendMessageStream,ChatSession.sendMessage,ChatSession.sendMessageStream) already append the whole exchange withaddAll(requestHistory).The change aligns
sendMessagewith the streaming path.requestHistoryis seeded with[message], so in the non-auto single-turn caseaddAll(requestHistory)records exactly the same user message as before — no behavior change there.Tests
Added
sendMessage retains auto-executed function turns in historytoserver_template_test.dart: a mocked two-turn exchange (first response afunctionCall, second the final text) assertshistoryends up with 4 entries — user message,functionCall,functionResponse, final reply — matching whatsendMessageStreamproduces.Validation
Ran from a standalone checkout of
packages/firebase_ai/firebase_ai(Flutter 3.47.5, headless):Expected length 4, Actual length 2.flutter test test/server_template_test.dart— all 6 pass.flutter test test/chat_test.dart— all pass; full package suiteflutter test— 353 passed, 9 skipped.