fresh-iron-75343
10/24/2025, 7:26 PMtall-airline-16756
10/24/2025, 7:26 PMtall-airline-16756
10/24/2025, 7:27 PMchat_ctx attribute of the Agent class. This attribute gives you access to the full conversation history, including user messages, agent responses, function calls, and their outputs—making it easier to keep track of everything.
Here’s a simple example to show you how you can retrieve the chat transcript:
from livekit.agents import Agent, function_tool
class MyAgent(Agent):
@function_tool()
async def get_full_chat_transcript(self) -> str:
transcript = []
for item in self.chat_ctx.items:
if item.type == "message" and hasattr(item, "text_content"):
role = item.role
content = item.text_content if item.text_content else ""
transcript.append(f"{role}: {content}")
elif item.type == "function_call":
transcript.append(f"Function Call: {item.name}({item.arguments}) [ID: {item.call_id}]")
elif item.type == "function_call_output":
transcript.append(f"Function Output: {item.output} [For Call ID: {item.call_id}]")
return "\n".join(transcript)
The chat_ctx.items list holds all the interaction items in the order they happened, including:
• Messages: User and assistant text input/output
• Function Calls: When function tools are invoked
• Function Outputs: The results returned by those function tools
This approach lets you easily access and work with the conversation transcript however you need. If you have any questions or want to explore this further, feel free to ask—I’m here to help!
Sources: README.md | Text and transcriptions | LiveKit Docs