DocsWorkflowsComponentsMachinemachine:agent:session:create

machine:agent:session:create

Runs one turn of a coding agent session against a working directory and returns the session it ran, the agent's final message, the tools it called and what the turn spent. The agent runs headless through its own CLI, which has to be installed on the machine the run happens on, and reports what it does as it does it on step.progress events, each carrying a type of session, message or tool on IO.Partial. A coding agent runs commands of its own, so the step is behind the same host permission as machine:shell:exec.

Options

NameTypeDescription
agentstringThe coding agent to run, one of claude-code, codex, gemini or opencode
agent_pathstringThe agent's executable, a bare name or a path, found on PATH by its usual name when empty
promptstringThe task handed to the agent as its first turn, or as the next turn of a resumed session
dirstringWorking directory the agent runs in; defaults to the pipeline cwd
session_idstringThe session to resume, as an earlier step returned it; empty starts a new session
modelstringThe model the agent runs on, as the agent names it (provider/model for opencode); empty keeps the agent's default
effortstringThe reasoning effort the agent runs at, as the agent names its levels; empty keeps the agent's default
args[]stringExtra command-line arguments handed to the agent's CLI, such as a permission mode or sandbox flag

Outputs

NameTypeDescription
session_idstringThe session the agent ran, which a later step passes back to resume it
messagestringThe agent's final message of the turn
modelstringThe model that answered, where the agent reported it or the step named it
tools[]ToolUseHow many times the agent called each tool, one entry per tool
  ↳ namestringThe tool the agent called, as the agent names it
  ↳ callsintHow many times the agent called it
usageUsageThe tokens the turn spent and what they cost, the agent's subagents included where its stream reports them
  ↳ 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
duration_msint64How long the agent ran

Example

name: Fix the failing test
actions:
  - name: fix
    component: machine:agent:session:create
    vars:
      agent: claude-code
      dir: ./project
      prompt: Run the test suite and fix whatever fails.
      args: ["--permission-mode", "acceptEdits"]

  - name: review
    component: machine:agent:session:create
    vars:
      agent: claude-code
      dir: ./project
      session_id: "{{ fix.session_id }}"
      prompt: Add a regression test for the fix.
      args: ["--permission-mode", "acceptEdits"]

outputs:
  session: "{{ review.session_id }}"
  summary: "{{ review.message }}"
  cost_usd: "{{ review.usage.cost_usd }}"