🚀 [firebase_ai] Support system/context message turns in chat history for backend or memory updates

オープン
#17,797 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
28/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
dart, firebase, flutter
領域
ai, api, mobile-dev

調査の方向性

package/firebase_ai/src/developer/api.dart、特に DeveloperSerialization.parseGenerateContentResponse から始め、issue で説明されている chat-history API を使って、報告された Content.system() エラーを再現してください。既存の user、model、system-instruction、FunctionResponse の処理を比較してください。完了条件は、backend または memory のイベントについて合意済みのサポート対象表現があり、その結果生じる history の動作がカバーされていることです。

索引モデルが issue の本文から書いたものです。

説明

Needs Attention plugin: ai type: enhancement

What feature would you like to see?

Feature Summary

Add support for injecting backend- or system-originated events and memory updates into the chat history as their own distinct turn type. This would allow these messages to be properly recognized by the AI model—without being misattributed to the user or model—and ensure the model has the right context for generating accurate, helpful responses. This could be accomplished by supporting a new message role (such as system or context) in the chat history, or by providing an explicit API for adding non-user, non-model context turns.

Description:

I’m building a Flutter AI chat app with firebase_ai: ^2.3.0 and need to inject extra context—such as backend-triggered events or memory updates—into the chat history so the model can provide informed responses.

However, adding Content.system() as a turn in the chat history results in the following error:

I/flutter (22326): Please use a valid role: user, model.
I/flutter (22326): #0   DeveloperSerialization.parseGenerateContentResponse (package:firebase_ai/src/developer/api.dart:103:56)

System content is only allowed as a system instruction, not as a message turn.

Why this is a problem

While FunctionResponse works for tool call responses, many events—like backend updates ("Your booking was rescheduled")—are triggered asynchronously, not by a user or model prompt or a model-initiated function call. Injecting these as FunctionResponse technically seems possible, but it feels like a workaround, and I'm not even sure if this actually works as intended since there was no function invocation.

Using a role of user for these events doesn't make sense, because the update or context did not originate from the user.

Using a role of model also doesn't make sense, as these messages are not generated by the model.

Question

  1. Is it supported or recommended to use FunctionResponse for backend events that aren't the result of a function call?
  2. Or is there a better way (e.g., a dedicated system/context message type, or allowing Content.system() in the message history) to inject backend or app-originated events into the chat?

Why this matters

  1. Enables the app to push backend or memory updates into the conversation history in the correct order
  2. Cleanly distinguishes between user/model/tool and system-originated events

Version:

  • firebase_ai: 2.3.0
  • Flutter stable
主要言語
Dart
スター
9.3k
フォーク
4.1k
平均マージ
4日 17時間
マージ済み PR(30日)
49

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

firebase/flutterfire のほかの issue

firebase/flutterfire の issue をすべて見る

似ている issue

Dart の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。