Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
Use AgentSession to keep conversation context between invocations.
Core usage pattern
Most applications follow the same flow:
- Create a session (
create_session()) - Pass that session to each
run(...) - Rehydrate by service conversation ID (
get_session(...)) or from serialized state
// 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)
Guide map
| Page | Focus |
|---|---|
| Session | AgentSession structure (session_id, service_session_id, state) and serialization |
| Context Providers | Built-in and custom context/history provider patterns |
| Storage | Built-in storage modes and external persistence strategies |