[firebase_ai]: TemplateChatSession.sendMessage drops auto-executed function call/response turns from history
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Dart
- Star
- 9.3k
- Fork
- 4.1k
- Merge trung bình
- 2 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 46
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của firebase/flutterfire
-
[firebase_auth]: authStateChanges() never emits null when the user is force-signed-out before the stream is listened to (iOS, macOS, Android)Có thể đã có người làm @JulianPscheid đã nhận 1 ngày trước. Đang mởNeeds Attention platform: android platform: ios platform: macos plugin: auth reproduced type: bug
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 15/100
firebase/flutterfire#18796 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
blocked: customer-response Needs Attention platform: ios plugin: messaging type: bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
firebase/flutterfire#18776 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[📚] Remote Config Windows Support still N/A on ReadmeCó thể đã có người làm @nightcityblade đã nhận 7 ngày trước. Đang mởblocked: customer-response good first issue Needs Attention platform: windows plugin: remote_config type: documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 30/100
firebase/flutterfire#18763 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[cloud_firestore]: a snapshots() listener cancelled while it registers is never removed nativelyCó thể đã có người làm @chiliec đã nhận 19 ngày trước. Đang mởNeeds Attention platform: android platform: ios platform: macos plugin: cloud_firestore reproduced type: bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
firebase/flutterfire#18724 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[firebase_storage] Windows native crash in upload progress callback, sink ownership and thread dispatchCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởblocked: flutter platform: windows plugin: storage reproduced type: bug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
firebase/flutterfire#18664 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của firebase/flutterfire
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: The daily reminder keeps its old language after the app language changesCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbacklog:low bug localization
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
simonoppowa/OpenNutriTracker#1366 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Mobile reading view shows a sender without display name as "<[email protected]>" with angle bracketsĐang mởai-driven-qa bug Cosmetic
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
linagora/tmail-flutter#4999 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
waiting for response
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 72/100
flutter/flutter#194381 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
newrelic/newrelic-flutter-agent#243 · 3 bình luận ·