Ask your agent fleet a question from a script

All articles

Once you run more than a few coding agents, the questions you ask most are small and repetitive. Is anything waiting on me? Which sessions are on the laptop? Has the one doing the migration finished yet? You can open a window and look, but the answer is a fact, and a fact is something a script can fetch.

DevThrottle ships a command line, cc-devthrottle, installed with the rest of it. It serves a person typing and a program asking equally well. Here are the handful of commands that turn those small questions into one line each.

Where the commands run

The fleet commands go to your Gateway, carrying the calling session's own key. Every DevThrottle session already has the pair in its environment (CC_GATEWAY_URL and CC_GATEWAY_SESSION_KEY), so the easiest place to run them is inside any agent you already have open. In a plain terminal without that pair, the fleet commands stop and say so. There is no port on your Director to discover, because it does not have one.

Is anything waiting on me?

session list prints the fleet as text: id, name, state and repository by default. It takes filters, so the question you care about is one command:

cc-devthrottle session list --state needs-you
  • States. --state takes needs-you, working, ready, snoozed and crashed, comma separated, so --state needs-you,crashed is the "what needs a person" view.
  • Where. --repo narrows to one repository by folder name or full path, and --machine to one computer.
  • What you see. --fields picks the columns, for example --fields number,name,state,machine. The session number is the short name you can say out loud.

Give the program JSON, and keep the warnings out of it

Add --json and the same list comes back as a bare array with every field, filters still applied. Two details make it safe to parse:

  • Warnings go to standard error. If the Gateway could not hear from every machine, the caveat that the list may be incomplete is printed to stderr, so stdout stays valid JSON and a person still sees the warning.
  • Empty is not the same as nothing running. In text mode, an empty answer says which it is: no session matches your filter, nothing is running in the fleet, or nothing came back but this is not the whole fleet. A script that treats an empty list as "all clear" should read stderr before it relaxes.

Wait for one session instead of polling

The other common script is "tell me when it is done". You do not need a loop of your own:

cc-devthrottle session wait 104 --until idle --timeout 1800

It takes a session number, id or exact name, and waits until that session is idle or, with --until needs-approval, until it is asking for permission. The default timeout is an hour. If the session exits first, or the timeout passes, the command fails with exit code 1 and says why, so the next line of your script can tell success from giving up. Add --json for a one-line answer.

Let a program see what it may run

A script, or an agent, should not guess at commands. Ask for the catalogue instead:

cc-devthrottle actions --json

Each entry names the command, its arguments, and mutatesState: whether it changes anything. That one flag is the easiest guardrail you can put on automation. A reporting script that only ever runs entries marked false sticks to the reads: it can look at the whole fleet without starting, stopping or changing anything in it. How calls are authorized, and what a session key may and may not do, is on the Control API page.

Put it on a schedule

When the useful thing is for work to happen without you, that is the Gateway's job rather than your operating system's, and it is one command:

cc-devthrottle schedule create --name "weekday tests" --machine YOUR-PC --repo D:/repos/my-project --cron "0 6 * * 1-5" --tz "America/Toronto" --seed "Run the test suite and fix what is red."

The name, machine, folder and time zone are required. Use --cron for a recurring job or --at with a local timestamp for a single run, and cc-devthrottle schedule list shows what is scheduled. Your machine's name is what cc-devthrottle session whoami prints.

Start here

Run cc-devthrottle session list from inside any session. If it answers, everything above will work. The walk-through is Driving DevThrottle from a script, and every command group is listed in the command reference.

Talk to usBook a 20-minute call