次の方法で共有


会話とメモリの概要

呼び出し間で会話コンテキストを保持するには、 AgentSession を使用します。

コア使用パターン

ほとんどのアプリケーションは、同じフローに従います。

  1. セッションの作成 (create_session())
  2. そのセッションをそれぞれに渡す run(...)
  3. サービス会話 ID (get_session(...)) またはシリアル化された状態からのリハイドレート
// Create and reuse a session
AgentSession session = await agent.CreateSessionAsync();

var first = await agent.RunAsync("My name is Alice.", session);
var second = await agent.RunAsync("What is my name?", session);

// Persist and restore later
var serialized = agent.SerializeSession(session);
AgentSession resumed = await agent.DeserializeSessionAsync(serialized);
# Create and reuse a session
session = agent.create_session()

first = await agent.run("My name is Alice.", session=session)
second = await agent.run("What is my name?", session=session)

# Rehydrate by service conversation ID when needed
service_session = agent.get_session(service_session_id="<service-conversation-id>")

# Persist and restore later
serialized = session.to_dict()
resumed = AgentSession.from_dict(serialized)

ガイド マップ

ページ フォーカス
セッション AgentSession 構造体 (session_idservice_session_idstate) とシリアル化
コンテキスト プロバイダー 組み込みおよびカスタムコンテキスト/履歴プロバイダー パターン
ストレージ 組み込みのストレージ モードと外部永続化戦略

次のステップ