tool_trace
¶
A record of the tool calls made while SensAI answers one message, so the chat can show how it got to its reply.
ARGS_LENGTH
module-attribute
¶
The most characters of a call's arguments kept for the chat, which shows them on one line.
RESULT_LENGTH
module-attribute
¶
The most characters of a call's result kept for the chat. A job report or the column list can be thousands, and the chat only previews it.
CHAT_AGENT
module-attribute
¶
The agent of a call the chat agent made itself, which is a hand-off to a specialist. A specialist's own calls carry the specialist's route (job_status, plot_config, ...).
ToolStatus
module-attribute
¶
ToolStatus = Literal['running', 'ok', 'rejected', 'failed']
How a call went: still running, returned a result, turned away by the tool with a reason the model was told (a refused plot edit, bad arguments), or never returned (the specialist gave up or the message hit its request limit).
Emit
module-attribute
¶
Sends one event to the chat as it happens, by name and payload.
-
Reference
mujoco_mojoutilslayersdojosensai
-
Reference
mujoco_mojoutilslayersdojosensai
ToolCallRecord
¶
Bases: BaseModel
One tool call, as the chat shows it.
-
Reference
mujoco_mojoutilslayersdojosensai
-
Reference
mujoco_mojoutilslayersdojosensai
id
instance-attribute
¶
id: int
Its place in the message, from 1, in the order the calls started.
agent
instance-attribute
¶
agent: str
Who called it: chat for a hand-off, else the specialist's route.
ToolTrace
dataclass
¶
ToolTrace(
emit: Emit | None = None,
calls: list[ToolCallRecord] = list(),
)
The tool calls one chat message made, from the chat agent and from every specialist it handed the request to.
Each agent's run gets a handler from handler (the chat agent's own goes through tap), which records a call when it starts and its outcome when it ends, and tells emit so the chat can show each one live. calls is the whole list once the message is done.
-
Reference
mujoco_mojoutilslayersdojosensai
-
Reference
mujoco_mojoutilslayersdojosensai
emit
class-attribute
instance-attribute
¶
emit: Emit | None = None
Called with tool_start as a call begins and tool_end as it finishes, or None to only record.
calls
class-attribute
instance-attribute
¶
calls: list[ToolCallRecord] = field(default_factory=list)
Every call so far, in the order it started.
tap
async
¶
tap(
agent: str, events: AsyncIterable[AgentStreamEvent]
) -> AsyncIterator[AgentStreamEvent]
Records the tool calls in events as they pass and gives every event on, unchanged, so a caller that reads the events for something else can use it in place of events.
Source code in src/mujoco_mojo/utils/layers/dojo/sensai/tool_trace.py
handler
¶
handler(
agent: str,
) -> Callable[
[RunContext[Any], AsyncIterable[AgentStreamEvent]],
Awaitable[None],
]
An event_stream_handler for the run of agent that records its tool calls and does nothing else.
Source code in src/mujoco_mojo/utils/layers/dojo/sensai/tool_trace.py
finish
¶
Marks every call that never returned as failed. Call it when the message is over, since a specialist that gave up or a message that ran out of requests leaves its call open.
Source code in src/mujoco_mojo/utils/layers/dojo/sensai/tool_trace.py
| Python | |
|---|---|