Headless runs and CI

Run one task from a script, read its exit code or JSON, and run it in CI.

 Ask a question

One task, no person

sylphyx -p runs one task without a person and exits: the reply on standard output, progress on standard error. It uses the same settings, keys and sessions as the interactive CLI.

sylphyx -p "Explain what src/parser.rs does"
sylphyx --mode auto-edit --max-steps 40 -p "Add doc comments to the public functions in src/lib.rs"
$OutputEncoding = [Text.UTF8Encoding]::new($false)
Get-Content -Raw -Encoding UTF8 task.md | sylphyx --mode plan -p -

The first line is for Windows PowerShell 5.1, the one Windows comes with: without it, letters outside English reach Sylphyx as question marks. PowerShell 7 does not need it.

Approvals without a person

Nobody is there to approve, so a call that would wait is refused, and the model is told so and goes on without it. The mode therefore decides what a headless run can do: plan and ask read and report; auto-edit also changes files inside the project but runs no commands; auto runs commands too, sandboxed on macOS and Linux and with the user's full rights on Windows. Without --mode, the mode saved in the settings is used, else Ask.

Exit codes

  • 0FinishedThe task finished.
  • 2Stopped earlyThe step limit, the budget, or a reply cut at the output limit. The reason is on standard error.
  • 1ErrorNo model, a refused key, no plan, or invalid settings.

JSON output

sylphyx --json -p "List the TODO comments in src"

--json prints one JSON object per line for every event of the session (each with a type), and last a line of type result:

The last lineJSON
{"type":"result","outcome":"finished","error":null,"session":42,"model":"anthropic/claude-sonnet-5-5","requests":7,"input_tokens":48210,"cached_tokens":39004,"output_tokens":2210,"cost_usd":0.071,"seconds":38.4}

outcome is finished, truncated, stopped, step_limit, budget or error; cost_usd is null for a model without a known price. A run that fails before its turn starts (no model, no plan, invalid settings) still ends with a result line: outcome error, the reason in error, and zeros. --resume with the session number continues it later.

Among the events, a line of type notice says something the run should know, for example that the budget cannot be enforced for a model with no known price: {"type":"notice","text":"…"}.

In CI

A headless run needs what any turn needs: a model key and a Sylphyx account with a current plan. On a computer nobody signs in on, such as a CI runner, both come from environment variables kept as secrets: the provider's key variable, and SYLPHYX_TOKEN, a session for your account. Make one on your own computer:

sylphyx account token

Approve it in the browser and the token is printed, not kept; store it as a secret. The runner checks it with the account service before each turn and saves nothing. (On a runner of your own, signing in once with sylphyx login --no-browser as the runner's user works too.) The download page shows what the latest release has. The example runs on a Windows runner of your own:

.github/workflows/sylphyx-task.ymlYAML
name: Sylphyx taskon:  workflow_dispatch:    inputs:      task:        description: What to do        required: truejobs:  run:    # A runner of your own with the Sylphyx CLI installed.    runs-on: [self-hosted, windows]    steps:      - uses: actions/checkout@v4      - name: Run the task        env:          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}          SYLPHYX_TOKEN: ${{ secrets.SYLPHYX_TOKEN }}          TASK: ${{ inputs.task }}        run: sylphyx --mode auto-edit --budget 3 -p $env:TASK      - name: Show what changed        run: git status --short

Give yours a name other than sylphyx.yml: that is the file the app's cloud runs write.