Do AgentTask have access to the previous chat_ctx?
# ask-ai
a
Do AgentTask have access to the previous chat_ctx?
t
Thanks for reaching out, Ahron. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — that's a great question. You're asking whether an
AgentTask
can access the previous
chat_ctx
(prior conversation context). Short answer: yes, but only if you pass it in. What you can do • By default, an
AgentTask
starts with a fresh conversation history. • If you want the task to be aware of prior messages, pass the current
chat_ctx
when you create the task:
Copy code
# Pass the current chat context to the task
result = await CollectConsent(chat_ctx=self.chat_ctx)
• When you use a
TaskGroup
, the shared
chat_ctx
is passed through to keep continuity across tasks. • Even if you don't pass
chat_ctx
directly, the full session history is available via
session.history
, which contains all messages before and during the task. If you'd like, tell me which pattern you're using (single task, TaskGroup, or session-based flow) and I can show a short example tailored to your setup. Sources: Tasks and task groups | LiveKit Documentation | Collect recording consent with tasks | LiveKit Documentation | Agents and handoffs | LiveKit Documentation