Loops and Graphs on Cursor: From Parallel Workers to a Real Agent Team

By | November 25, 2026

Part 3 turned loop_graph.py into a team: a done-well checklist, labelled edges, a red route, a short team memory, and one human yes before any prompt change. A spec with "runner": "cursor" already sent the workers through that same graph. The weekly proposal still called claude, with --tools "" and --json-schema, and the default improve model was sonnet.

This post is that call. The checks, the gate, and the rule from Part 2 still hold: a shell command decides that the work is done.


1. What a Cursor worker already did

Each task goes to the Cursor agent CLI (agent 2026.01.23 on this machine, or CURSOR_AGENT_BIN):

agent -p --output-format json --model composer-2.5 --force --sandbox disabled \
  --workspace <cwd> --resume <session> "<prompt>"

--force lets the headless worker run commands. --sandbox disabled lets it edit the tree the checks read. --resume keeps the fix rounds in one session. The prompt is the last argument. Claude sends its prompt on stdin and passes --permission-mode.

The rest of Part 3 is one code path. done_well, needs, "when": "red", ASK ME FIRST, REMEMBER, <spec>.memory.md, <spec>.runs.jsonl, ESCALATION.md, --graph, --report, --accept, and --reject do not look at which binary is running. check_cmd is still a single check.

2. The proposal call

--improve ranks the agents of the current spec version by the lowest first-pass rate, then the lowest green rate, then the most turns. It asks for one change to prompt, input, output, never, or ask_first. The checks stay as they are. The proposal is written to <spec>.proposal.json. --accept is the only step that edits the spec.

Claude’s call is tool-less, and the CLI checks the shape:

claude -p --model sonnet --tools "" --no-session-persistence \
  --settings '{"disableAllHooks": true}' --output-format json \
  --json-schema '<schema>' --system-prompt '<lead instructions>'

For a Cursor spec the same step is a read-only ask. agent --help describes --mode ask as Q&A that does not edit:

agent -p --mode ask --output-format json --model composer-2.5 \
  --workspace <empty temp dir> "<lead instructions, the schema, the log tail>"

The workspace is an empty temporary directory. It is removed when the call returns, so this step does not open the repo the workers edit. Workers keep --force and --sandbox disabled. The proposal call leaves both off.

The default improve model follows the runner: composer-2.5 for Cursor, sonnet for Claude. Set improve_model in the spec to override it. A model name containing fable is refused before the process starts. If the JSON result names a Fable model in model, modelName, model_id, or modelUsage, the proposal is refused and no file is written.

3. Where the JSON schema goes

Claude returns structured_output, filled under --json-schema. The Cursor answer is the result string (or text). The prompt tells the model to print one object and then stop:

{"field": "prompt|input|output|never|ask_first", "value": "<text>", "why": "<one or two sentences>"}

The script keeps the first object in that answer whose field is one of those five names and whose value and why are non-empty strings. A Markdown fence around the object is read the same way. A result that is already an object is read the same way. Both runners then write the same <spec>.proposal.json, and --accept and --reject stay as they are in Part 3.

Claude’s improve call passes --settings with disableAllHooks. On a logged-in Cursor run, hooks configured for every session still apply. The empty workspace keeps that call out of the repo’s project rules.

4. What I ran

agent status says this machine is not logged in, so this post has no live Cursor proposal and no cost for one.

I did run the real binary with the new flags and a one-line prompt. It accepted the flags and stopped before a model call:

Error: Authentication required. Please run 'agent login' first, or set CURSOR_API_KEY environment variable.

With a stub in place of agent I ran --improve on a one-node spec whose history was a RED coder:

  • The argv was -p --mode ask --output-format json --model composer-2.5 --workspace <temp>. The temp directory was gone afterwards. --force and --sandbox were absent. An explicit improve_model of gpt-5.4 was passed through.
  • A result wrapped in a json fence became ask_first: installing packages, cost $0.050 from total_cost_usd.
  • A result that was already an object became a new prompt.
  • A result whose model was fable-5 was refused. improve_model: fable was refused before the stub started.
  • An answer with no JSON object exited no proposal and wrote no file.
  • --accept appended that ask_first item, moved the spec to v2, and kept team.v1.json.

The Claude path, stubbed the same way, still sends --tools "" and --json-schema, and still reads structured_output.

5. A Cursor spec

The tasks are the ones from Part 3. The runner and the two model fields are the Cursor ones. cwd is an absolute path: the script does not expand ~.

{
  "runner": "cursor",
  "model": "composer-2.5",
  "improve_model": "composer-2.5",
  "max_iters": 3,
  "final_cmd": "git -C /home/me/work/billing-api push",
  "final_cwd": "/home/me/work/billing-api",
  "tasks": []
}
agent login   # once, before the first real run
python3 ~/scripts/loop_graph.py ~/teams/billing-pagination.json
python3 ~/scripts/loop_graph.py ~/teams/billing-pagination.json --approve
python3 ~/scripts/loop_graph.py ~/teams/billing-pagination.json --improve

Read the proposal against the weakest agent’s log before you --accept it. Part 3’s first live proposal told the coder to stop asking. The ask was the right behaviour: the other option was to install packages into a shared interpreter.


Series: Loops and Graphs in Antigravity (Part 1) · Part 2: deterministic checks and a final approval gate · Part 3 is the team, in the same folder.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.