What you need to know
Unattended agents do recurring or triggered engineering work with nobody watching each step: a nightly dependency audit, a weekly report, a first diagnosis of every failed build, a multi-hour upgrade toward "all tests pass". With no person in the loop, the design must answer what a person would: when to stop, what to do when stuck, who to tell, and what the agent may never do on its own.
Three shapes
| Shape | Trigger | Examples |
|---|---|---|
| Goal-driven | Started once, runs until a condition holds | Upgrade a framework until tests pass and the type checker is clean |
| Scheduled | A schedule, an HTTP call or a repository event | Daily audit, weekly stale-PR report, triage of new issues |
| Event-driven responder | An alert or CI failure | Read the failed build's logs, diagnose, propose a fix |
Where to run them
| Option | Fits when |
|---|---|
| Cloud scheduled tasks | Same prompt on a recurring trigger, no need for your network; nothing to host (runs at most hourly, starts from a fresh clone) |
Headless Claude Code (claude -p) in CI or cron | The job needs your environment or pipeline |
| Agent SDK service | The work belongs inside your own product or webhook service |
Never wait for input
An unattended run that hits a permission prompt hangs until the job times out. Run with a non-interactive permission mode that denies anything not pre-approved, and list exactly the tools the job needs. Bypass permissions mode removes the safety net and belongs only in isolated containers.
Consistent, bounded runs
- Declare the configuration: skip auto-discovered local configuration and pass the settings and MCP config the job needs, so every runner starts the same. (Skipping discovery also skips CLAUDE.md, Skills and hooks, so do not use it where those are what is being tested.)
- Bound the loop with a maximum number of turns and a budget.
- Return structured output: JSON constrained by a schema, read by the next script, instead of free text parsed with regular expressions.
- Chain stages by session ID: capture it from the first run's JSON output and resume that session for the second stage, rather than pasting a plan into a fresh session.
Goal-driven runs
A goal needs a completion condition that can be checked from the run's output (the test results), not the agent's belief that it is done. Add checkpoints (commits at safe points) so progress survives interruptions, and notify the owner on completion or when the run is stuck, with a summary. No self-merging: the result arrives as a pull request through review.
Event-driven responders
A CI first responder starts on the failure event, investigates with read access and narrowly scoped tools (no production credentials), posts its diagnosis in the team channel, and opens any fix as a pull request through normal review. It does not push to main or skip failing jobs.
For responders driven by metrics, put deterministic detection first: control bands and run rules so only sustained or extreme readings trigger action, tiers (log, diagnose read-only, act through pre-approved runbooks only), and a cap on automated actions per period with escalation to a person when it is reached. A noisy metric that triggers 20 rollbacks in a night needs better detection and a cap, not a responder that widens its own thresholds.
State across runs
Scheduled agents are stateless unless the design gives them state. A triage job that runs every 15 minutes and asks maintainers the same question repeatedly needs a durable record of what it handled and asked, read at the start of each run.
In the exam
Unattended-operation items describe a job that hangs, loops, repeats itself, breaks a downstream script, acts too often or acts without review. Choose the control that makes it non-interactive, bounded, checkable, stateful, structured, notified or gated. Distractors use bypass mode, raise timeouts, rely on someone watching, remove limits, let agents merge or widen their own thresholds.
Check your understanding
A headless lint-fix job hangs until timeout because Claude waits for permission. What is the fix?
Show answer
Answer: D. Calls that would prompt are refused instead of waiting; bypass mode removes all checks.
A nightly audit's free-text output keeps breaking the ticketing script that reads it. What should change?
Show answer
Answer: B. Structured output is reliable to parse; formatting requests and regexes break when wording changes.
Which completion condition fits a goal-driven framework upgrade?
Show answer
Answer: A. A goal must be checkable from what the run produces, not from the agent's own belief.
Apply it: Design Riverbend's CI first responder
Riverbend wants its CI first responder to handle every failed main-branch build: read the logs, decide whether the failure is flaky or real, find the likely cause, and propose a fix. Today the job sometimes hangs on permission prompts, sometimes posts long free-text messages nobody reads, and once retried a flaky test 30 times in an hour.
- Specify how the job runs: trigger, permission mode and tools.
- Define the output it produces and where it goes.
- Bound its authority and its activity.
- Design state and escalation so it does not repeat itself or go unnoticed.
Show model answer
1. Running. Triggered by the CI failure event on main. Headless Claude Code with a non-interactive mode that denies anything not pre-approved; allowed tools: read files, gh run view for logs, git log, and creating a branch and draft pull request. A turn limit of 25 and a budget per run.
2. Output. JSON matching a schema: verdict (flaky, real, unknown), failing_test, suspected_commit, evidence (log lines), proposed_fix (a draft pull request link or none). A script posts a three-line summary in the owning team's channel with the links.
3. Bounds. No push to main, no merge, no re-running or skipping jobs, no production credentials. For flaky verdicts, at most one re-run of the job per failure; any further action is a pull request that quarantines the test, through review.
4. State and escalation. A record per failing test (last verdict, actions taken, pull requests opened) is read at the start of each run, so the same test is not diagnosed again within the hour. If a "real" failure has no proposed fix after two runs, or main has been red for 60 minutes, the on-call engineer is paged with the summary.