Skip to main content

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

FieldTypeDescription
messageslist[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:
TypeFields
AgentActivityThreadMessagerole, content.text (string), content (rich content).
AgentActivityThreadToolCalltool_name, payload, result.
AgentActivityThreadReasoningtype ("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}")

Audit tool usage

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:
StatusCause
404Task has no activity log (e.g. it never started).
500Server error or network failure.