Documentation Index
Fetch the complete documentation index at: https://docs.xpander.ai/llms.txt
Use this file to discover all available pages before exploring further.
Task.aget_activity_log returns the full thread of activity for a task: user messages, assistant messages, tool calls, tool results, reasoning steps, sub-agent triggers, and auth events. Unlike task.aevents() (live SSE for in-flight tasks), the activity log is a historical record you can fetch at any time, including for completed tasks.
from xpander_sdk import Tasks
from xpander_sdk.models.activity import (
AgentActivityThreadMessage,
AgentActivityThreadToolCall,
AgentActivityThreadReasoning,
)
task = await Tasks().aget(task_id="task_xyz")
log = await task.aget_activity_log()
for msg in log.messages:
if isinstance(msg, AgentActivityThreadMessage):
print(f"[{msg.role}] {msg.content.text}")
elif isinstance(msg, AgentActivityThreadToolCall):
print(f"[tool] {msg.tool_name}({msg.payload}) → {msg.result}")
elif isinstance(msg, AgentActivityThreadReasoning):
print(f"[reasoning:{msg.type}] {msg.thought}")
Parameters
None.
Returns AgentActivityThread
| Field | Type | Description |
|---|
messages | list[AgentActivityThread*] | Ordered union of message types (see below). |
| (other fields) | – | Thread metadata (id, agent_id, organization_id, …). |
The messages list is a tagged union. Common variants:
| Type | Fields |
|---|
AgentActivityThreadMessage | role, content.text (string), content (rich content). |
AgentActivityThreadToolCall | tool_name, payload, result. |
AgentActivityThreadReasoning | type ("think" / "analyze"), thought. |
(There are additional sub-types for sub-agent triggers and auth events: branch on isinstance or type(msg).__name__ to handle them.)
Examples
Just the user/assistant transcript
log = await task.aget_activity_log()
for msg in log.messages:
if isinstance(msg, AgentActivityThreadMessage):
print(f"{msg.role.upper()}: {msg.content.text}")
log = await task.aget_activity_log()
tool_calls = [m for m in log.messages if isinstance(m, AgentActivityThreadToolCall)]
print(f"Task {task.id} called {len(tool_calls)} tools:")
for tc in tool_calls:
print(f" - {tc.tool_name}")
Reasoning trace
reasoning = [
m for m in log.messages
if isinstance(m, AgentActivityThreadReasoning)
]
for r in reasoning:
print(f"[{r.type}] {r.thought}")
Sync version
log = task.get_activity_log()
Errors
Raises ModuleException if the activity log can’t be retrieved:
| Status | Cause |
|---|
| 404 | Task has no activity log (e.g. it never started). |
| 500 | Server error or network failure. |