chilly-garage-64056
11/27/2025, 10:57 AMtall-airline-16756
11/27/2025, 10:57 AMtall-airline-16756
11/27/2025, 10:58 AMChatContext and becomes the ongoing controller of the session. Agents persist for the lifetime of their control over the session and can maintain instructions, tools, and conversational flow long-term.
• Task: a short-lived, stateless execution unit created by an agent to complete a specific objective and return a typed result. A task temporarily takes control of execution, runs to completion (or error), returns its result to the parent agent, and is then destroyed.
2) Context management
• Agents keep session-level state: each Agent is associated with an AgentSession and a ChatContext that represent ongoing conversational context, toolsets, and instructions. That state persists across turns while the agent remains active.
• Tasks run within the parent agent's session context: a task sees and can operate on the current AgentSession and pipeline context while it runs, but it does not become a persistent owner of that state. When a task completes, the parent agent resumes with any results the task returned. Tasks do not retain or continue evolving context after completion.
3) Pipeline components and tools
• Agents define their toolset and instruction set persistently while active; they can call tools and orchestrate pipelines across many turns.
• Tasks may declare their own temporary tools and instructions to accomplish their single objective. Those tools/instructions are scoped to the task's lifetime. Pipeline components (LLM, STT, TTS, plugins) are used via the same session-level plumbing; tasks reuse the session’s pipeline rather than creating an independent, persistent pipeline.
4) WebSocket connections to external services (when they are reestablished)
• WebSocket connections to external services (LLM providers, STT/TTS plugins, etc.) are managed per-session by the AgentSession. Because both handoffs and tasks operate within the same `AgentSession`:
◦ A handoff does not by itself close or reestablish those connections—the AgentSession continues, so existing WebSocket connections persist and are reused.
◦ A task likewise does not cause connections to be dropped or re-created; it uses the active session connections while executing.
• Connections are only reestablished if the underlying connection is severed (network errors, timeouts, provider-side disconnects) or explicitly replaced/overridden by configuration. The lifecycle of agents vs tasks does not trigger automatic reconnection.
5) What "do not persist" means for tasks
• "Do not persist" means tasks are ephemeral: they exist only for the duration of their execution. They do not remain registered as active controllers of the session, they do not maintain ongoing state after completion, and they do not continuously listen or react to new events once finished. Any state produced by a task is returned to the initiating agent; if persistent behavior is needed, the agent (or a long-lived agent instance) must own that state.
If you'd like, I can:
• Show an example sequence of messages and session state during a handoff vs during a task run.
• Outline how to design tools/instructions when you need persistent behavior vs one-off operations. Sources: Agents and handoffs | LiveKit docs | Workflows | LiveKit docs | Agents (Node.js) | livekit/livekit_composite | DeepWiki | Tasks and task groups | LiveKit docschilly-garage-64056
11/27/2025, 11:07 AMSomeTask(AgentTask[bool]) - all it care about is the boolean state prop.
While an Agent() accesses AgentSession[SomeMainStateObject]
As a result, if I manage state independently from Session, Agent and Task - what difference remains?tall-airline-16756
11/27/2025, 11:08 AM