[firebase_ai]: TemplateChatSession.sendMessage drops auto-executed function call/response turns from history
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
調査の方向性
Start with lib/src/server_template/template_chat.dart, especially TemplateChatSession.sendMessage, and compare how requestHistory is added in sendMessageStream and the other chat methods. The report includes a reproduction using chat.history; verify that it contains the user message, function call and response turns, and final response. An open linked pull request (#18758) is already addressing this issue.
索引モデルが issue の本文から書いたものです。
説明
Is there an existing issue for this?
- I have searched the existing issues.
Which plugins are affected?
Other
Which platforms are affected?
Web
Description
Affected plugin: firebase_ai (not in the dropdown). The code is pure Dart, so other platforms are likely affected too; we have only built for Web.
When TemplateChatSession.sendMessage auto-executes functions (TemplateAutoFunctionDeclaration), only the original message and the final model response are added to history:
// lib/src/server_template/template_chat.dart, sendMessage
if (!shouldAutoExecute) {
if (response.candidates case [final candidate, ...]) {
_history.add(message);
// ...
_history.add(normalizedContent);
}
return response;
}
The intermediate turns collected in requestHistory are discarded: the model's functionCall content and the function responses. On the next sendMessage, the model no longer sees what its tools returned. For example, a createCharacter call that returned a new id is gone from history, so a follow-up call that needs that id has nothing to refer to.
The other three code paths keep the whole exchange with _history.addAll(requestHistory):
TemplateChatSession.sendMessageStreamChatSession.sendMessageChatSession.sendMessageStream
So this looks like an oversight in this one path rather than intended behavior.
Expected: after auto-executed function turns, history contains the user message, each model functionCall turn, each function response turn and the final response, as sendMessageStream does. Likely fix:
_history.addAll(requestHistory);
_history.add(normalizedContent);
Actual: history contains only the user message and the final response.
This is still the code on main as of today. We found it while building function calling on a server prompt template, and worked around it by using sendMessageStream.
Reproducing the issue
- Create a server prompt template that declares one function, e.g.
getValue, and includes{{history}}. final chat = FirebaseAI.googleAI().templateGenerativeModel().startChat('<template-id>', inputs: {}, tools: [TemplateTool.functionDeclarations([TemplateAutoFunctionDeclaration(name: 'getValue', parameters: {}, callable: (_) => {'value': 42})])]);await chat.sendMessage(Content.text('Call getValue and tell me the result.'));The model calls the function and the SDK auto-executes it.- Inspect
chat.history: it has 2 entries (user message, final reply). ThefunctionCallandfunctionResponseturns are missing. Doing the same withsendMessageStreamgives 4 entries.
Firebase Core version
4.14.0
Flutter Version
3.44.1
Relevant Log Output
No error is raised; the turns are silently missing from `chat.history`.
Flutter dependencies
Expand Flutter dependencies snippet
firebase_ai: 4.0.0
firebase_core: 4.14.0
Additional context and comments
Related, but already fixed on main in 6eb250f (#18685), not yet released: in 4.0.0, function responses are sent with role function, which the template endpoint rejects with Role 'function' is not supported. Please use a valid role: SYSTEM, SYSTEM_1, USER, ASSISTANT, DEVELOPER, CONTEXT, USER_CONTEXT, MODEL, USER. Mentioned only so it isn't re-reported. A release including that fix would be welcome.
- 主要言語
- Dart
- スター
- 9.3k
- フォーク
- 4.1k
- 平均マージ
- 2日 2時間
- マージ済み PR(30日)
- 38
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
firebase/flutterfire のほかの issue
-
🚀 [firebase_core] Bump Firebase iOS SDK (12.19.0 → 13.0.0)対応中かも @SelaseKay が 5 日前に担当しました。 オープンNeeds Attention platform: ios plugin: core type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
firebase/flutterfire#18769 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[firebase_messaging]: Android: a burst of background messages starts a FlutterEngine per service start, and can lose all of them対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンNeeds Attention platform: android plugin: messaging type: bug
難易度 1/5 1時間未満 初心者へのやさしさ 45/100
firebase/flutterfire#18789 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
blocked: customer-response Needs Attention platform: ios plugin: messaging type: bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
firebase/flutterfire#18776 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
[📚] Remote Config Windows Support still N/A on Readme対応中かも @nightcityblade が 6 日前に担当しました。 オープンblocked: customer-response good first issue Needs Attention platform: windows plugin: remote_config type: documentation
難易度 1/5 1時間未満 初心者へのやさしさ 30/100
firebase/flutterfire#18763 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
[cloud_firestore] iOS: transaction.get() after the native timeout aborts the app ("A transaction object cannot be used after its update callback has been invoked")対応中かも @SelaseKay が 2 日前に担当しました。 オープンNeeds Attention platform: ios plugin: cloud_firestore reproduced type: bug type: crash
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
firebase/flutterfire#18755 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
firebase/flutterfire の issue をすべて見る
似ている issue
-
documentation good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
djazairdev/wilayas#22 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
rajput-hemant/calculator#199 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
leancodepl/app-rating#35 ·
-
Mobile login: "Sign In" button is squashed to 16 px with its label cut while the keyboard is openオープンai-driven-qa bug claude
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
linagora/tmail-flutter#4976 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
aaronified/fluenough#503 ·
メンテナーはふだん 1 日以内に返信