pub struct ResultMessage {Show 80 fields
pub subtype: ResultSubtype,
pub is_error: bool,
pub duration_ms: u64,
pub duration_api_ms: u64,
pub ttft_ms: Option<u64>,
pub ttft_stream_ms: Option<u64>,
pub time_to_request_ms: Option<u64>,
pub time_to_request_phases_ms: Option<BTreeMap<String, u64>>,
pub turn_start_resume_kind: Option<TurnStartResumeKind>,
pub handoff_intake_phases_ms: Option<BTreeMap<String, u64>>,
pub process_turn_index: Option<u64>,
pub time_to_request_cpu_ms: Option<u64>,
pub time_to_request_loop_lag_ms: Option<u64>,
pub time_to_request_major_faults: Option<u64>,
pub process_rss_mib_turn_start: Option<u64>,
pub process_anon_mib_turn_start: Option<u64>,
pub process_rss_mib_result: Option<u64>,
pub process_anon_mib_result: Option<u64>,
pub process_peak_rss_mib: Option<u64>,
pub process_cpu_ms_between_turns: Option<u64>,
pub process_wall_ms_between_turns: Option<u64>,
pub process_cpu_ms_turn: Option<u64>,
pub process_wall_ms_turn: Option<u64>,
pub input_attachments_detail: Option<InputAttachmentsDetail>,
pub resume_store_confirm_detail: Option<ResumeStoreConfirmDetail>,
pub time_to_request_from_spawn_ms: Option<u64>,
pub warm_spare_claimed: Option<bool>,
pub flag_fetch_kick: Option<String>,
pub time_origin_ms: Option<u64>,
pub request_sent_wall_ms: Option<f64>,
pub first_request_input_tokens: Option<u64>,
pub first_content_frame_ms: Option<u64>,
pub first_stream_post_ms: Option<u64>,
pub first_stream_post_ack_ms: Option<u64>,
pub first_stream_post_queue_wait_ms: Option<u64>,
pub first_stream_post_queued_behind: Option<StreamPostQueuedBehind>,
pub first_stream_post_wall_ms: Option<f64>,
pub frame_received_wall_ms: Option<f64>,
pub frame_enqueued_wall_ms: Option<f64>,
pub frame_intake_phases_ms: Option<BTreeMap<String, u64>>,
pub turn_started_wall_ms: Option<f64>,
pub turn_start_phases_ms: Option<BTreeMap<String, u64>>,
pub turn_start_control_requests_ms: Option<u64>,
pub first_text_post_ms: Option<u64>,
pub first_text_post_queue_wait_ms: Option<u64>,
pub first_text_post_queued_behind: Option<StreamPostQueuedBehind>,
pub first_text_post_wall_ms: Option<f64>,
pub user_message_uuid: Option<String>,
pub user_message_server_received_wall_ms: Option<f64>,
pub user_message_uuids: Vec<String>,
pub resume_reason: Option<String>,
pub local_command: Option<String>,
pub queued_turn_count: Option<u64>,
pub num_turns: i32,
pub result: Option<String>,
pub session_id: String,
pub total_cost_usd: f64,
pub usage: Option<UsageInfo>,
pub permission_denials: Vec<PermissionDenial>,
pub errors: Vec<String>,
pub uuid: Option<String>,
pub api_error_status: Option<u16>,
pub api_error_code: Option<String>,
pub api_error_origin: Option<String>,
pub api_error: Option<String>,
pub stop_reason: Option<String>,
pub terminal_reason: Option<String>,
pub interrupted_by_shutdown: Option<bool>,
pub result_index: Option<u64>,
pub fast_mode_state: Option<String>,
pub fast_mode_disabled_reason: Option<FastModeDisabledReason>,
pub model_usage: Option<BTreeMap<String, ModelUsageEntry>>,
pub model_usage_since_last_result: Option<BTreeMap<String, ModelUsageEntry>>,
pub subagent_stats: Option<SubagentStats>,
pub safety_stops: Option<u64>,
pub structured_output: Option<Value>,
pub deferred_tool_use: Option<DeferredToolUse>,
pub origin: Option<MessageOrigin>,
pub runner_exit: Option<RunnerExit>,
pub startup_failure_reason: Option<StartupFailureReason>,
}Expand description
Result message for completed queries
Fields§
§subtype: ResultSubtype§is_error: bool§duration_ms: u64§duration_api_ms: u64§ttft_ms: Option<u64>Time to first token, in milliseconds.
ttft_stream_ms: Option<u64>Time to first streamed token, in milliseconds.
time_to_request_ms: Option<u64>Time from session start until the first request was issued, in milliseconds.
time_to_request_phases_ms: Option<BTreeMap<String, u64>>How time_to_request_ms was spent, in
integer milliseconds per phase, summing to it exactly (CLI 2.1.285+):
system_prompt, system_prompt_rebuild (a second assembly of the
system prompt, run when the tool pool re-read after the message was
handled differs from the turn-start pool; CLIs before 2.1.287 report
it inside system_prompt), resume_other (settling, before the
turn’s own prompt, tool calls that an earlier run left open or the
session’s client handed over — see
turn_start_resume_kind — excluding
four parts that have keys of their own: resume_store_confirm,
resume_staged_files_wait, resume_connector_wait and
turn_start_tool_run; CLIs before 2.1.287 report these five as one
turn_start_resume key), process_user_input (excluding
input_images, input_attachments, input_command and
input_hooks, which have keys of their own on 2.1.287+),
transcript_persist, init_message, engine_pickup,
memory_recall_wait, memory_context_wait, autocompact,
query_setup, tool_schema_build, message_normalization,
client_creation and other (the remainder no phase covers). A phase
that did not run is absent; other is always present. Open set —
keep unrecognized phase names. Present where time_to_request_ms is,
on CLAUDE_CODE_REMOTE sessions and hosts that set
CLAUDE_CODE_EMIT_STARTUP_TIMING; absent elsewhere.
turn_start_resume_kind: Option<TurnStartResumeKind>What the turn was given to settle before its own prompt; the
resume_* phases and turn_start_tool_run in
time_to_request_phases_ms say how
long that took (CLI 2.1.287+). A turn given more than one kind reports
the first in TurnStartResumeKind order. Present where
time_to_request_phases_ms is.
handoff_intake_phases_ms: Option<BTreeMap<String, u64>>On a turn the session’s client handed over (turn_start_resume_kind
is turn_handoff), how long its turn_handoff control request waited
from its arrival on the session server’s SSE stream until the input
loop read it, in integer ms, split into startup_wait,
control_requests_ahead and user_frames_ahead (each absent when 0)
and before_read (the rest, always present). The values sum to the
wait. Open set — keep unrecognized part names. Present only on
results that carry turn_start_resume_kind (CLI 2.1.300+).
process_turn_index: Option<u64>Number of earlier turns of this CLI process that sent a
main-conversation model request: 0 is the process’s first turn to
reach the model, not the conversation’s first. Turns stopped or
failed after sending count but carry no value, so values can skip.
Where one process hosts several sessions, each has its own count.
Present where
time_to_request_phases_ms is
(CLI 2.1.285+).
time_to_request_cpu_ms: Option<u64>CPU time (user plus system) the CLI process used from turn start
until it sent the turn’s first main-conversation model request, in
milliseconds (CLI 2.1.285+). Near time_to_request_ms, the window
was mostly computing; near 0, mostly waiting. It adds up all threads,
so it can exceed the window, and leaves out child processes. Present
where time_to_request_phases_ms is, unless the runtime reports no
resource usage or the process hosts other sessions too.
time_to_request_loop_lag_ms: Option<u64>The longest single stall of the session’s thread between turn start
and the turn’s first main-conversation model request, in
milliseconds, measured as how late a 50 ms timer fired (CLI
2.1.285+): the real stall can be up to 50 ms longer, and a few ms is
timer noise. Only the first two minutes are measured. Present where
time_to_request_phases_ms is.
time_to_request_major_faults: Option<u64>Major page faults (waits for memory to be read from disk) by the
process in the
time_to_request_cpu_ms window;
Windows also counts faults needing no disk read. Present where
time_to_request_cpu_ms is (CLI 2.1.285+).
process_rss_mib_turn_start: Option<u64>Resident memory of the CLI process at turn start, in whole MiB
(VmRSS), child processes left out. Sent only by a worker Anthropic
hosts, with telemetry on, on Linux (not WSL); there it is present,
always with process_rss_mib_result,
where process_turn_index is, unless the process hosts other
sessions too (CLI 2.1.300+).
process_anon_mib_turn_start: Option<u64>The anonymous part (RssAnon: heaps, stacks, JIT code) of
process_rss_mib_turn_start, in
whole MiB (CLI 2.1.300+).
process_rss_mib_result: Option<u64>As process_rss_mib_turn_start,
read again just before this result is built: the level the turn
leaves behind (CLI 2.1.300+).
process_anon_mib_result: Option<u64>The anonymous part of
process_rss_mib_result, in whole
MiB (CLI 2.1.300+).
process_peak_rss_mib: Option<u64>The most memory the process has had resident from its start until
this result (VmHWM), in whole MiB — not this turn’s peak alone
(CLI 2.1.300+).
process_cpu_ms_between_turns: Option<u64>CPU time (user plus system, all threads, no child processes) the CLI
process used from the end of its previous turn to this turn’s start,
in ms. Divide sums of it by sums of
process_wall_ms_between_turns,
which always comes with it, for CPU per second. Present where
process_cpu_ms_turn is, from the
process’s second turn on (CLI 2.1.300+).
process_wall_ms_between_turns: Option<u64>Monotonic wall time of the
process_cpu_ms_between_turns
stretch, in ms (CLI 2.1.300+).
process_cpu_ms_turn: Option<u64>CPU time, counted as in
process_cpu_ms_between_turns,
from this turn’s start until just before this result is built,
including the waits for the model and tools. Always comes with
process_wall_ms_turn. Sent only by the
workers named under
process_rss_mib_turn_start
(CLI 2.1.300+).
process_wall_ms_turn: Option<u64>Monotonic wall time of the
process_cpu_ms_turn stretch, in ms
(CLI 2.1.300+).
input_attachments_detail: Option<InputAttachmentsDetail>What the input_attachments phase of time_to_request_phases_ms did
on the turn, to tell a wait inside one attachment producer from a
process that was busy. Present on turns where the phase started,
unless nothing of it is known (CLI 2.1.288+).
resume_store_confirm_detail: Option<ResumeStoreConfirmDetail>How the resume_store_confirm phase of time_to_request_phases_ms
was spent. Present where that phase is, in a session whose transcript
goes to a hosted store: on the result of a handed-off turn whose lines
were confirmed and that went on to a model request (CLI 2.1.290+).
time_to_request_from_spawn_ms: Option<u64>Time from spawning a worker/spare until the first request was issued, in milliseconds.
warm_spare_claimed: Option<bool>Whether a warm spare process was claimed for this request.
flag_fetch_kick: Option<String>Whether this process started its start-up feature-flag fetch before
the wait for it, or why not: the same value as system/init’s
startup_timing.flag_fetch_kick. An open string set
(started_in_init_*, started_after_init_*, not_asked_warm,
settings_pending_*, launch_excluded, not_eligible; an _empty
or _warm ending is the flag cache at that moment). Present only
where time_to_request_from_spawn_ms is, and only when start-up
judged it (CLI 2.1.288+).
time_origin_ms: Option<u64>Epoch-ish timestamp origin used by CLI timing instrumentation.
request_sent_wall_ms: Option<f64>Wall-clock epoch milliseconds when the API request was sent (fractional; from CLI timing instrumentation).
first_request_input_tokens: Option<u64>Input tokens of the model call whose send time is
request_sent_wall_ms: input_tokens + cache_read_input_tokens + cache_creation_input_tokens from that call’s
message_start, so a consumer can group turn latency by prompt size
(CLI 2.1.286+). Present only with request_sent_wall_ms, and only
when the sum is above zero.
first_content_frame_ms: Option<u64>Time until the first content frame of the stream arrived, in milliseconds (CLI 2.1.260+ timing instrumentation).
first_stream_post_ms: Option<u64>Time until the first stream POST was issued, in milliseconds (CLI 2.1.260+).
first_stream_post_ack_ms: Option<u64>Time until the first stream POST was acknowledged, in milliseconds (CLI 2.1.260+).
first_stream_post_queue_wait_ms: Option<u64>Time the first stream POST spent waiting in the outbound queue, in milliseconds (CLI 2.1.278+).
first_stream_post_queued_behind: Option<StreamPostQueuedBehind>What the first stream POST was queued behind (CLI 2.1.278+).
first_stream_post_wall_ms: Option<f64>Wall-clock epoch milliseconds when the first stream POST was issued (fractional; CLI 2.1.260+).
frame_received_wall_ms: Option<f64>Wall-clock epoch milliseconds when the triggering send’s frame arrived
on a session reading its input from the session server’s SSE stream
(--sdk-url), before the input loop read it (CLI 2.1.278+). With
frame_enqueued_wall_ms and
turn_started_wall_ms it splits the
stretch between the server’s persist and request_sent_wall_ms into
transit, the input loop’s handling of the frame, its wait on the
command queue, and the turn’s own work. Present only together with
request_sent_wall_ms, and only when the transport recorded the
receipt; absent on a local stdin host.
frame_enqueued_wall_ms: Option<f64>Wall-clock epoch milliseconds when the input loop put the triggering
send’s frame on the command queue (CLI 2.1.278+). Present exactly
when frame_received_wall_ms is.
frame_intake_phases_ms: Option<BTreeMap<String, u64>>How the triggering send’s frame spent the time between
frame_received_wall_ms and
frame_enqueued_wall_ms, in integer
milliseconds per intake step (CLI 2.1.282+): before_read (until the
input loop read the frame, including any wait behind earlier frames
and a first message’s wait for the worker to finish starting),
dedup, flag_settle, receive_hook, attachments,
admission_wait (held behind a pending model switch, a pending MCP
server-set change, start-up work the worker still owed its first
turn, or an earlier held frame), admit_check (the host’s decision
whether to queue the frame, when it had to be awaited) and other.
Steps that did not run are absent; before_read and other are
always present. The values sum to the enqueued-minus-received gap
unless a step came out negative and was clamped to 0. Open set —
keep unrecognized step names. Present exactly when
frame_received_wall_ms is, except from older producers.
turn_started_wall_ms: Option<f64>Wall-clock epoch milliseconds when the turn’s clock started: the
anchor duration_ms, ttft_ms, ttft_stream_ms,
time_to_request_ms, first_content_frame_ms, first_stream_post_ms
and first_stream_post_ack_ms are measured from (CLI 2.1.278+).
Present exactly when
frame_received_wall_ms is.
turn_start_phases_ms: Option<BTreeMap<String, u64>>How the time from
frame_enqueued_wall_ms to
turn_started_wall_ms was spent, in
integer milliseconds per step of the host’s work through its message
queue (CLI 2.1.285+): idle, earlier_turn, after_turn,
background_wait, entry_joins, sdk_mcp_update, loop_top,
session_start_wait, first_command, mcp_prewait, repo_wait,
turn_joins, tool_pool, commit, after_arm, turn_gate,
turn_open, engine_setup, tool_reread, cwd and other. Each
step is where the host was at the time, which for part of the stretch
may be an earlier message’s turn. A step that rounds to 0 is absent;
other is always present. The values sum to the started-minus-enqueued
gap, except that they can exceed it (usually by 1 ms from rounding).
Open set — keep unrecognized step names. Present only when
frame_received_wall_ms is, and absent from older producers.
turn_start_control_requests_ms: Option<u64>Of the time from frame_enqueued_wall_ms to turn_started_wall_ms,
the integer milliseconds in which the claude -p host’s message
reader was held by control requests (such as mcp_set_servers or
set_permission_mode) instead of reading the next message (CLI
2.1.285+). It overlaps
turn_start_phases_ms and is not part
of its sum. Absent when 0.
first_text_post_ms: Option<u64>Time until the first text POST was issued, in milliseconds (CLI 2.1.278+).
first_text_post_queue_wait_ms: Option<u64>Time the first text POST spent waiting in the outbound queue, in milliseconds (CLI 2.1.287+).
first_text_post_queued_behind: Option<StreamPostQueuedBehind>What the first text POST was queued behind (CLI 2.1.287+); the same
value set as
first_stream_post_queued_behind.
first_text_post_wall_ms: Option<f64>Wall-clock epoch milliseconds when the first text POST was issued (fractional; CLI 2.1.278+).
user_message_uuid: Option<String>Wire uuid of the user message this result answers.
user_message_server_received_wall_ms: Option<f64>The server_received_wall_ms
of the user message user_message_uuid
names, copied unchanged, so the session server can measure from its
own receipt to request_sent_wall_ms (CLI 2.1.286+). Present only with
request_sent_wall_ms, and only when that message carried a positive
finite number there.
user_message_uuids: Vec<String>Client uuids of every user message whose prompt this turn consumed, in
consumption order — all members of a prompt batch the host merged into
this one turn, plus any queued user message folded into the running
turn between tool rounds. Always contains user_message_uuid; at most
64 entries. Absent on delivery-failure/zeroed results and from CLIs
before 2.1.259 (fall back to user_message_uuid).
resume_reason: Option<String>Why this turn was the automatic re-run of a turn a worker restart
interrupted (CLAUDE_CODE_RESUME_INTERRUPTED_TURN): the host’s
CLAUDE_CODE_RESUME_REASON when it set one (host_draining,
checkpoint_restore, container_recreated, …), else
interrupted_turn. Present on a headless re-run’s result, success or
error; absent on every other turn, on the Remote Control bridge’s
per-turn synthetic results, and from CLIs before 2.1.268.
local_command: Option<String>The local slash command that produced this result when the query loop was bypassed (success results only). Absent when the turn went to the model and from CLIs before 2.1.268.
queued_turn_count: Option<u64>User-initiated sends still waiting in the command queue when this result was produced. Greater than 0 means at least one more user turn follows without further input, barring cancellation. Absent on fatal startup results, on surfaces without a command queue, and from CLIs before 2.1.259.
num_turns: i32§result: Option<String>§session_id: String§total_cost_usd: f64§usage: Option<UsageInfo>§permission_denials: Vec<PermissionDenial>Tools that were blocked due to permission denials during the session
errors: Vec<String>Error messages when is_error is true.
Contains human-readable error strings (e.g., “No conversation found with session ID: …”). This allows typed access to error conditions without needing to serialize to JSON and search.
uuid: Option<String>§api_error_status: Option<u16>HTTP status code when the result is an API error (e.g., 429, 500, 529)
api_error_code: Option<String>The api_error_code of the API error that ended the turn (see
AssistantMessage::api_error_code): the server’s
error.details.error_code when it is an identifier. Absent when the
turn did not end on an API error, when the response carried no code,
and from CLIs before 2.1.274.
api_error_origin: Option<String>The api_error_origin of the API error that ended the turn (see
AssistantMessage::api_error_origin): first_party when Anthropic’s
own API sent the response. Absent when the turn did not end on an API
error or the origin is anything else; treat an unknown value as
absent (CLI 2.1.300+).
api_error: Option<String>The typed kind of the API error that ended the turn (see
AssistantMessage::api_error). Absent when the turn did not end on
an API error, when the error has no typed kind, and from CLIs before
2.1.285; treat an unknown value as absent.
stop_reason: Option<String>Why generation stopped (e.g., end_turn, max_tokens)
terminal_reason: Option<String>Why the session ended (e.g., “completed”)
interrupted_by_shutdown: Option<bool>Present, and true, when the host of a multi-tenant worker shut the
worker down while this turn ran, the shutdown was the first thing to
abort the turn, and the turn is left for the session’s next worker.
The other frames of the ending, and terminal_reason, look the same
as a client’s Stop; this tells the two apart. A success result can
carry it (a shutdown during a Stop hook), and a result without it can
still be a shutdown’s (CLI 2.1.300+).
result_index: Option<u64>Delivery sequence of this result within the run: how many results the
run numbered before this one, starting at 0, in the order the process
writes them. A result whose write fails still consumes its number, so
a gap means a result was lost. Distinct from num_turns. Numbered by
the process hosting the run (claude -p); a local client relaying a
cloud session passes the cloud numbering through and its own locally
built error results carry none. Absent from CLIs before 2.1.268.
fast_mode_state: Option<String>Fast mode toggle state (e.g., “off”)
fast_mode_disabled_reason: Option<FastModeDisabledReason>Why fast mode can’t serve right now. Absent when nothing blocks it.
A paused-after-rate-limit run is not reported here; it rides
fast_mode_state as "cooldown".
model_usage: Option<BTreeMap<String, ModelUsageEntry>>Per-model cost breakdown, keyed by model name (e.g. "claude-opus-4-8").
model_usage_since_last_result: Option<BTreeMap<String, ModelUsageEntry>>Per-model usage and cost of the calls this process counted since it
wrote its previous result (since it started, for its first), keyed and
shaped like modelUsage and covering the same calls. Sum it over a
conversation’s results instead of subtracting modelUsage totals: each
call is stated on at most one result, whatever a resume or a kill does
to modelUsage. Calls that finish after a result (a background
subagent, a late title call) are stated on the next result. Nothing is
carried across processes, so calls counted after a process’s last
result (including a turn in flight when it is killed) are stated
nowhere. A model with nothing counted is left out; {} means nothing
was counted, and absent is not {}. Set by stream-json and --sdk-url
runs only; not set on hand-numbered error results (start-up failures,
errors that escape the run). Absent from CLIs before 2.1.309. Marked
@internal upstream.
subagent_stats: Option<SubagentStats>Subagents started through the Agent tool in this session, as running
totals. Cumulative like modelUsage: read the latest result rather
than summing across results. Absent from CLIs before 2.1.239.
safety_stops: Option<u64>How many times a safety system has stopped one of this session’s
model calls (main loop, subagents, forked skills, compaction and other
internal calls), as a running total since the session started in this
process: a refusal stop reason, a refusal answered on a fallback
model, output the API’s content filter stopped, and (where the build
can tell) a server-side safety monitor block. Never sum across
results. Not saved, so a resumed session or a mid-session /clear
starts again at 0: over a stored log any result above 0 means a stop
happened, and a later 0 does not cancel it. Absent from CLIs before
2.1.292. Marked @internal upstream.
structured_output: Option<Value>Structured-output payload returned by the model, when enabled.
deferred_tool_use: Option<DeferredToolUse>Deferred tool-use termination payload.
origin: Option<MessageOrigin>Provenance of the message/run.
runner_exit: Option<RunnerExit>Set by the self-hosted runner on the result it synthesizes when the session process fails to start or exits abnormally. Absent on normal results and on CLIs before 2.1.266.
startup_failure_reason: Option<StartupFailureReason>Why Claude Code refused to start. Set on the zeroed
error_during_execution result a stream-json run writes before
exiting on a known startup failure; errors carries the same text as
stderr. Failures that used to end with stderr alone write that result
only when the host sets CLAUDE_CODE_STARTUP_FAILURE_RESULTS. Absent
on every other result, on startup failures without a known cause, and
from CLIs before 2.1.274.