DocsWorkflowsComponentsMachinemachine:agent:session:read

machine:agent:session:read

Reads one session a coding agent keeps on the machine the run happens on, with its messages, its turns, the subagents it spawned and what each of them spent. Tool inputs and outputs are left out, since they are bulky and routinely carry whatever secrets the agent saw.

Options

NameTypeDescription
agentstringThe coding agent that ran the session, one of claude-code, codex or opencode
session_idstringThe session to read, as machine:agent:session:list or machine:agent:session:create returned it
homestringThe agent's state directory, such as ~/.claude; empty reads the agent's own default

Outputs

NameTypeDescription
sessionSessionThe session and its level-one metrics
  ↳ idstringThe session id, which the agent resumes the session by
  ↳ agentstringThe coding agent that ran the session
  ↳ titlestringThe session's title, where the agent named it
  ↳ dirstringThe working directory the session started in
  ↳ git_branchstringThe git branch checked out when the session started
  ↳ versionstringThe version of the agent CLI that wrote the session
  ↳ started_atstringWhen the session's first record was written, RFC 3339 in UTC
  ↳ ended_atstringWhen the session's last record was written, RFC 3339 in UTC
  ↳ messagesintHow many user and assistant text messages the session holds
  ↳ tools[]ToolUseHow many times the agent and its subagents called each tool
    ↳ namestringThe tool the agent called, as the agent names it
    ↳ callsintHow many times the agent called it
  ↳ models[]ModelUsageWhat each model spent across the session and its subagents
    ↳ modelstringThe model as the agent's provider names it
    ↳ usageUsageThe tokens the model spent and what they cost
      ↳ input_tokensint64Prompt tokens the provider did not serve from its cache
      ↳ output_tokensint64Completion tokens, reasoning included
      ↳ cache_read_tokensint64Prompt tokens served from the provider's prompt cache
      ↳ cache_write_tokensint64Prompt tokens written into the provider's prompt cache
      ↳ reasoning_tokensint64The part of the output tokens the model spent thinking
      ↳ cost_usdfloat64What the tokens cost in US dollars, zero where nothing recorded or priced it
  ↳ usageUsageWhat the session and its subagents spent in total
    ↳ input_tokensint64Prompt tokens the provider did not serve from its cache
    ↳ output_tokensint64Completion tokens, reasoning included
    ↳ cache_read_tokensint64Prompt tokens served from the provider's prompt cache
    ↳ cache_write_tokensint64Prompt tokens written into the provider's prompt cache
    ↳ reasoning_tokensint64The part of the output tokens the model spent thinking
    ↳ cost_usdfloat64What the tokens cost in US dollars, zero where nothing recorded or priced it
  ↳ cost_sourcestringWhere the cost came from, reported by the agent, priced from the tokens, or empty when unknown
  ↳ pathstringThe file or directory the session was read from
messages[]MessageThe user and assistant text messages of the session itself, in order
  ↳ rolestringWho wrote it, user or assistant
  ↳ textstringThe message text
  ↳ atstringWhen it was written, RFC 3339 in UTC
  ↳ modelstringThe model that wrote an assistant message
turns[]TurnEach prompt of the session with its duration and usage
  ↳ idstringThe turn as the agent identifies it
  ↳ started_atstringWhen the turn started, RFC 3339 in UTC
  ↳ duration_msint64How long the turn took, zero where the agent did not record it
  ↳ modelstringThe model that answered the turn
  ↳ effortstringThe reasoning effort the turn ran at
  ↳ usageUsageWhat the turn spent, its subagents excluded
    ↳ input_tokensint64Prompt tokens the provider did not serve from its cache
    ↳ output_tokensint64Completion tokens, reasoning included
    ↳ cache_read_tokensint64Prompt tokens served from the provider's prompt cache
    ↳ cache_write_tokensint64Prompt tokens written into the provider's prompt cache
    ↳ reasoning_tokensint64The part of the output tokens the model spent thinking
    ↳ cost_usdfloat64What the tokens cost in US dollars, zero where nothing recorded or priced it
subagents[]SubagentEvery agent the session spawned, at any depth
  ↳ idstringThe subagent as the agent identifies it
  ↳ parent_idstringThe subagent or session that spawned it
  ↳ depthintHow many spawns down from the session it sits, one for a direct child
  ↳ kindstringThe kind of subagent, as the agent names its type or role
  ↳ descriptionstringWhat the subagent was spawned to do, or its nickname
  ↳ modelstringThe model the subagent ran on
  ↳ tools[]ToolUseHow many times the subagent called each tool
    ↳ namestringThe tool the agent called, as the agent names it
    ↳ callsintHow many times the agent called it
  ↳ usageUsageWhat the subagent spent itself
    ↳ input_tokensint64Prompt tokens the provider did not serve from its cache
    ↳ output_tokensint64Completion tokens, reasoning included
    ↳ cache_read_tokensint64Prompt tokens served from the provider's prompt cache
    ↳ cache_write_tokensint64Prompt tokens written into the provider's prompt cache
    ↳ reasoning_tokensint64The part of the output tokens the model spent thinking
    ↳ cost_usdfloat64What the tokens cost in US dollars, zero where nothing recorded or priced it
  ↳ total_usageUsageWhat the subagent and every subagent below it spent
    ↳ input_tokensint64Prompt tokens the provider did not serve from its cache
    ↳ output_tokensint64Completion tokens, reasoning included
    ↳ cache_read_tokensint64Prompt tokens served from the provider's prompt cache
    ↳ cache_write_tokensint64Prompt tokens written into the provider's prompt cache
    ↳ reasoning_tokensint64The part of the output tokens the model spent thinking
    ↳ cost_usdfloat64What the tokens cost in US dollars, zero where nothing recorded or priced it
errors[]ErrorThe failures the session recorded
  ↳ atstringWhen it happened, RFC 3339 in UTC
  ↳ messagestringWhat failed, as the agent recorded it
permission_modestringThe permission or approval mode the session last ran under
effortstringThe reasoning effort the session last ran at
contextContextWindowHow full the context window was at the last request
  ↳ sizeint64The tokens the context window holds, zero where the agent did not record it
  ↳ usedint64The tokens the last request put into it
rate_limits[]RateLimitThe account's usage limits as the provider last reported them
  ↳ namestringWhich limit it is
  ↳ used_percentfloat64How much of the limit is used, from 0 to 100
  ↳ window_minutesintThe length of the window the limit counts over
  ↳ resets_atstringWhen the window resets, RFC 3339 in UTC

Example

name: Read back a Codex session
actions:
  - name: session
    component: machine:agent:session:read
    vars:
      agent: codex
      session_id: 0199b000-0000-7000-8000-00000000000a

outputs:
  messages: "{{ session.messages }}"
  turns: "{{ session.turns }}"
  subagents: "{{ session.subagents }}"
  tokens_in: "{{ session.session.usage.input_tokens }}"