SagentsLiveDebugger.UserRequests
(Sagents LiveDebugger v0.6.4)
Copy Markdown
Reads user request data for display: the request number a message was
produced under, the tokens it used, and the :user_request_started and
:user_request_completed events.
A user request is one human message and all the work done for it. Sagents
versions that track them stamp each message's metadata[:user_request_seq],
keep the current number in Sagents.State.user_request_seq, and broadcast
the two events. Older versions do none of this, so every read here tolerates
the key, field or event being absent and returns nil in that case. Callers
render nothing for nil.
Summary
Functions
Returns the current user request number held by an agent state, or nil
when no request has started or the state has no such field.
Formats a user request event for the event stream, or returns nil for any
other event.
Returns the user request number a message was produced under, or nil.
Returns true when a message is a summary that replaced older history.
Returns %{input: integer, output: integer} for the tokens a message used,
or nil. :subagent_usage reads the usage a sub-agent spent on a task
tool message instead.
Pairs each message with its index and the user request number to show a
divider for: the number when it differs from the last one seen, else nil.
Messages with no number never open a divider.
Functions
@spec current_seq(map() | nil) :: pos_integer() | nil
Returns the current user request number held by an agent state, or nil
when no request has started or the state has no such field.
Formats a user request event for the event stream, or returns nil for any
other event.
The map carries the :type and :summary every event has. A completed
request adds :status, :assistant_message_count and :tool_calls_label,
and :input/:output when its token usage is known.
@spec seq(map()) :: pos_integer() | nil
Returns the user request number a message was produced under, or nil.
Returns true when a message is a summary that replaced older history.
@spec usage(map(), :usage | :subagent_usage) :: %{input: non_neg_integer(), output: non_neg_integer()} | nil
Returns %{input: integer, output: integer} for the tokens a message used,
or nil. :subagent_usage reads the usage a sub-agent spent on a task
tool message instead.
@spec with_dividers([map()]) :: [{map(), non_neg_integer(), pos_integer() | nil}]
Pairs each message with its index and the user request number to show a
divider for: the number when it differs from the last one seen, else nil.
Messages with no number never open a divider.