Flint

Running Flint headless

A Flint agent headless run is one command: give it a task, and it exits with JSON and an exit code your script can check.

Short answer: flint --headless --task "..." runs a task with nobody present, prints a JSON object with the result, the cost and the token count, and exits with a code that tells you whether the task finished, made no progress, or was stopped by a limit. When a step would normally need approval, Flint refuses it and moves on, so the run never hangs waiting for input. A --budget cap and a --time-limit keep any single run bounded.

Setup is a one-time step: a provider, an API key, a care level. Install Flint before the first scripted call.

Where headless mode fits

Headless mode is built for automation you can describe in advance, and it is the wrong tool when a person has to make a call halfway through.

It fits when:

  • You have a clear, bounded task to automate in a script, a CI job or cron.
  • You need structured JSON output your pipeline can parse and act on.
  • You want the run to exit cleanly instead of stalling when it meets something it cannot handle alone.
  • You want a hard budget or time ceiling on every run.
  • You want to resume a run that was cut short, with --session.

It does not fit when:

  • The task regularly needs a person to approve actions partway through. Those actions are refused, not deferred, so steps that depend on them may never complete.
  • The task is exploratory or open-ended. You cannot predict what it will need, so it will refuse more than it finishes.
  • You are on macOS and need a platform the project tests on. Flint's automated tests cover Windows and Linux.
  • The work needs back-and-forth with a person to refine the result.

What you get from a headless run

One invocation, one result. This call runs a task inside a project folder with a spend ceiling:

flint --headless --task "run the test suite and report the failures" --cwd ./project --budget 0.50

When the run ends, it prints a JSON object with the response, the cost and the token count. Your script reads those three values instead of scraping terminal output. Two flags change the shape of the run: --time-limit puts a ceiling on wall-clock time, and --session names the run so a later call can pick it up again with the same identifier. That second one matters in a pipeline, because a step stopped by a limit can be retried or extended without doing the task again from the start. The exit code carries the outcome: the task ran to its end, the task got nowhere, or a budget or time limit ended the run. Branch on the code and you do not need to parse the body.

InterfaceHow it runsGood for
--headless flagOne invocation, exits with JSON and an exit codeScripts, CI steps, cron jobs
StdioLong-lived subprocess; JSON lines on stdin and stdoutEditors, shells and tools that keep a session open
Local HTTP APIStays running; a program connects after a PIN pairing stepLocal services that send requests over time

The setup a headless run needs is the same one interactive use needs. Set up Flint once and the scripted call inherits it.

What it costs to run, and the trade-off

A headless run costs what the model provider charges for the tokens it uses, and nothing else. Flint is free, open source under the MIT licence, with no paid plan and no account with us; requests go from your machine to the provider you chose. --budget 0.50 caps the run, money limits are set separately with a cost limit per message and an optional budget per session, and /budget shows what a session has spent so far. The JSON from the run carries the cost and the tokens, and the receipt after each turn lists tools used, files changed, tokens in and out, time and cost. If the provider refuses the key or the account is empty, Flint does not quietly switch to another model, so a failure stays visible in the pipeline instead of turning into a different result.

The trade-off is the one that makes headless mode useful in the first place. A headless run gives up the ability to ask a question, in exchange for the ability to run alone. When the task is ambiguous or hits an action the guard would stop on, the run does not surface the question: it does what it can and exits. A job you would supervise in three minutes can come back partial if a needed step was refused. Two things follow. The task description carries more weight headless than it does in a conversation, so write it to stay inside what a model can finish without asking. And the model matters more: a weaker model makes more mistakes no matter how the agent around it is configured. Run a new job interactively once to confirm it completes cleanly before you put it in a pipeline.

Frequently asked questions

What do the exit codes from a headless run mean?

There are three outcomes and each has its own code: the task ran to completion, the task made no progress, or the run was stopped by a budget or time limit. Branch on the code rather than parsing the JSON body, and handle the stopped case separately from the no-progress case, because only the stopped one is worth retrying with more budget, more time or a smaller task.

What happens when Flint needs approval for a risky action mid-run?

The action is refused at once, the agent is told why, and the run carries on with the steps it can still complete, so the call always returns. The JSON result lists the refused calls, so your script sees which action was refused without reading a log.

Can I resume a headless run that hit a time or budget limit?

Yes. Pass the session identifier from the previous call to --session and the run continues where it stopped, so a pipeline can retry a step that hit a ceiling without repeating the work it already did.

Can I use free models for headless tasks?

Yes, with the caveats that apply to free mode anywhere: those models are slower, often rate-limited, and the list of what is free changes without notice. Open an interactive session and run /model free to see which free models can call tools and how they are doing right now, then rely on that choice in automation.

How is the stdio interface different from --headless?

--headless is fire and exit: one task, one result, process gone. Stdio keeps Flint running as a subprocess and lets a host send messages over JSON lines on stdin and stdout, which suits an integrating tool that needs a session that persists rather than a fresh process per task. The local HTTP API covers programs on the same machine that connect after a PIN pairing step.

How do I see what a headless run spent?

The JSON the run prints carries the cost and the token counts. Inside a named session, /budget shows the spending accumulated so far, and the receipt after each turn lists tools used, files changed, tokens in and out, time and cost.

How to start

Flint needs Node.js 22.12 or newer, and it installs as one npm package:

npm install -g flint-agent

Run flint once after that. The first run is a short setup: pick a provider, enter an API key, choose a care level. It is stored in ~/.flint, a folder in your home directory that updates do not touch, and FLINT_DATA_DIR or --data-dir points it somewhere else. From then on a headless task is one more command:

flint --headless --task "describe what to do" --cwd ./project --budget 0.50

Set up Flint walks through the provider, the key and the care level before your first pipeline call. If you would rather not pay a provider for these jobs, free mode covers running Flint on free models that can call tools.