Skip to Content
kusaw docsv1.0.0

Use an agent inside your step

A custom step can start the agent CLI you already configured.

A custom step can start the agent CLI you already configured. That is Claude Code, or the Cursor CLI with the model setting it accepts. Kusaw does not choose one for you. Pass a runner preset (read_only, edit, or interview) rather than assembling vendor flags by hand.

kusaw agent-args prints the argv the built-in runner would use for that CLI: the command, isolation flags, and, when you pass --model, the model. Your step runs that argv instead of assembling vendor flags by hand.

kusaw claude-args stays as an alias of kusaw agent-args --provider claude-code. Its output is the same.

The default provider is Claude Code. A step that already has KUSAW_AGENT_PROVIDER set (from the factory) can omit --provider.

On a demo repo, Claude Code:

Terminal
kusaw agent-args --preset read_only
# same as:
kusaw claude-args --preset read_only

Cursor, after it is enabled in allowed_providers:

Terminal
kusaw agent-args --provider cursor --preset read_only

Read-only is the default review shape. Edit is the default build shape. Pass the printed argv to the process you start, with the request's worktree as the working directory and the prompt on stdin.

--model is passed through only when given, unchanged. The helper keeps no model list and adds nothing about endpoints or credentials.

From a custom step

Keep the handshake and result contract from Write your first step. When you want an agent turn, spawn "$KUSAW_BIN" agent-args (or cache its output), then spawn the printed command. Forward progress if the agent CLI emits it. End with ok, fail with feedback, retry, or reject as you would for any other program.

Do not hard-code a model name, an endpoint, or credentials. The user already configured the CLI. If the step config includes model, kusaw agent-args passes the setting that CLI accepts; if model is empty, that user's default stays.

Interview is Claude Code only. Cursor refuses it with the same capability message the built-in runner uses.

Claude Code in a turn step

A turn step runs once per question, so each run starts a new agent process. To keep one Claude Code session across the questions, take the session id from the agent's stream-json output and return it as turn.resume_id with await_input. Kusaw sends it back unchanged in request.turn.resume_id on the next run. Pass it to --resume-session, and the printed argv continues that session:

Terminal
kusaw claude-args --preset read_only --resume-session "$RESUME_ID"

Add --fork to pass --fork-session as well. resume_id is at most 256 bytes. The step still runs the user's configured Claude Code; Kusaw adds no model, endpoint or credentials.

Complete pipelines that call kusaw agent-args from POSIX sh are in Example pipelines.

On this page