Build an agent that runs on a script

This builds the cheap half of a pipeline: an Agent that runs a script on an interval, finds what needs attention, and hands anything that needs real thought to a second agent with a prompt.

Create a new Agent from the Agents view and set it to run a script rather than a prompt. Give it a long interval to begin with — every fifteen or thirty minutes is plenty while you are watching it — since you can always tighten it later.

Write the script, then grant it the tools it needs and nothing more, one at a time, from the Allowed Tools list. A first version that only lists threads and prints what it found is a good place to stop and look; see What a script is allowed to touch.

Press "Run now" and read the log and the calls it made. Remember that those calls are real — if you are not ready for it to change anything yet, grant nothing, run it, and check the shape of what it found first.

Give it a memory. Save the ids it has already handled into the workspace's saved values at the end of each run, and skip them at the start of the next — that one change is the difference between a loop and a loop that repeats itself forever.

Finally, assign it to a workspace and let it run. When it finds something worth acting on, have it leave a message in a thread for a prompt-driven agent to pick up on its own next check-in, exactly as in Build a Watcher / Addresser strategy — the script finds the work, the prompt does the thinking. If it drives anything only one agent should touch at a time, give it a lock too.

Try asking

"Create an Agent called "Stale Thread Sweeper" that runs a script every 30 minutes, assign it to my "pr-reviews" workspace, and have it list unresolved threads, record the ids it has already looked at in workspace state, and resolve anything untouched for a week."

Calls: create_agent, update_workspace, list_threads, set_workspace_state, resolve_thread