DocsWorkflowsComponentsMachinemachine:agent:session:list

machine:agent:session:list

Lists the sessions coding agents keep on the machine the run happens on, each with its tokens, cost, models and tool calls, the subagents it spawned included. A session whose agent recorded no cost is priced from the run's price table, and stays uncosted with an empty cost_source when a model it ran is not in that table.

Options

NameTypeDescription
agentstringThe coding agent whose sessions to list, one of claude-code, codex or opencode; empty lists every one of them
homestringThe agent's state directory, such as ~/.claude; empty reads the agent's own default, and it needs an agent
dirstringKeeps the sessions that ran in this directory or below it; a relative one is read against the pipeline cwd
sincestringKeeps the sessions active at or after this time, RFC 3339 or a YYYY-MM-DD date
untilstringKeeps the sessions that started before this time, RFC 3339 or a YYYY-MM-DD date
limitintThe most sessions to answer, the most recently active first

Outputs

NameTypeDescription
sessions[]SessionThe matching sessions, the most recently active first
  ↳ 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

Example

name: What the agents spent this week
actions:
  - name: recent
    component: machine:agent:session:list
    vars:
      dir: ./project
      since: "2026-10-14"
      limit: 50

outputs:
  sessions: "{{ recent.sessions }}"