Build Autonomous Agents
Build the smallest autonomous system that can produce and verify the intended
outcome. Keep the workload contract portable even when Flue is the selected
runtime.
1. Ground the Workload
Read the target's instructions, domain context, architecture, tests, delivery
controls, security boundaries, and existing runtime integration.
State:
- the user or operational outcome
- whether the workload is a product capability or SDLC automation
- trigger, owner, input, output, and completion condition
- allowed data, tools, repositories, network access, secrets, and side effects
- required human approval, cancellation, and rollback points
First test whether deterministic code, an existing application service, a
script, or a CI job can solve the problem. Do not add an agent when those are
sufficient.
2. Select the Smallest Unit
| Need |
Unit |
| Deterministic operation |
Function or application service |
| Bounded capability the model may call |
Tool |
| Reusable application-controlled orchestration |
Action |
| Finite inspectable operation |
Workflow |
| Continuing stateful interaction |
Agent |
| Focused separable responsibility |
Subagent |
Use a subagent only when its independent context, tools, or evaluation boundary
improves the result enough to justify delegation.
3. Write the Execution Contract
Define before implementation:
- validated input and output schemas
- model-visible context, Skills, and tools
- deterministic validation and application of results
- work identity, deduplication key, state owner, and retention
- isolation and permission boundary
- timeout, token or spend budget, concurrency, and stop condition
- retry, idempotency, recovery, duplicate-effect handling, and failure owner
- durable checkpoint, next wake condition, progress deadline, and reconciliation
- eval cases, telemetry, alerts, and incident owner
Separate probabilistic judgment from deterministic effects. Prefer a typed
proposal that application code validates and applies over letting model output
mutate business state directly.
4. Select and Verify the Runtime
Use the target's existing runtime when it meets the contract. For a TypeScript
system that needs a harness-first agent runtime, Flue is the current default
candidate, not part of the product contract.
Before adopting or changing Flue:
- Detect the installed version, package manager, deployment target, and
existing integration.
- Use the installed CLI's
flue docs search and flue docs read commands
first because those docs match the installed version.
- Check official upstream docs, changelog, package metadata, and types when
adopting or upgrading.
- Prefer the latest reviewed stable release. Do not adopt a nightly merely
because it is newer.
- Read REFERENCE.md for current Flue boundaries and migration
hazards.
Do not copy imports from @flue/runtime/internal; they are not a portable
public integration boundary.
5. Implement One Vertical Slice
For a product capability:
- keep authentication, authorization, business data, provider credentials,
persistence, and application of results application-owned
- expose meaningful queued, running, review, success, and failure states
- make any consequential result reviewable before application where risk
requires it
For SDLC automation:
- pin the repository revision and use an isolated worktree or sandbox
- grant the minimum repository, network, and secret permissions
- produce a reviewable patch, report, or other bounded artifact
- run the repository's Fast Check and relevant Full Gates
- never merge, deploy, or publish without explicit authority
Start deterministic seams with a failing behavior test and agent judgment with
a representative failing eval case. Implement the narrowest path from input
through verified outcome before adding channels, schedules, subagents, or
generalized abstractions.
6. Prove Safety and Recovery
- Treat local host execution as trusted execution, not isolation.
- Keep conversation state, workspace state, and business state distinct.
- Do not assume an interrupted finite workflow resumes at an arbitrary
TypeScript step.
- Persist every useful increment and the next eligible action outside the live
model session. Every routine non-terminal state must have a wake condition or
a reconciler that owns progress; a human prompt is not a scheduler. A required
human response waits on a durable correlated event with a deadline and
escalation; it is never inferred or auto-approved.
- Detect expired claims and missed progress deadlines. Inspect retained state
and external effects before a bounded requeue; alert the named failure owner
when safe recovery is not possible.
- Put external side effects behind application-owned idempotency keys.
- Use a durable external orchestrator when step-level resumability is required.
- Keep model-visible data, logs, traces, and run history free of unnecessary
secrets and personal data.
7. Evaluate and Observe
Test representative success, refusal, malformed output, tool failure, timeout,
retry, duplicate delivery, cancellation, and permission-denied cases. Assert
schemas, tool calls, side effects, latency, and cost where relevant.
Emit enough structured evidence to answer:
- what triggered the run
- which version and configuration ran
- what tools and effects occurred
- why it stopped
- whether the outcome passed deterministic checks and evals
Complete the work only when the bounded outcome works end to end, failure and
recovery behavior is demonstrated, permissions and budgets are explicit, and
the runtime can be replaced without changing the product contract. An idle
system has no admissible signal; a paused, blocked, or partial run exposes its
reason, owner, retained checkpoint, and next wake or escalation condition.
Related Skills
- scaffold-harness - assess maturity and runtime need
- coding-discipline - implement the smallest safe change
- completion-gate - verify before claiming completion
- product-craft - define product value and human oversight
- scaffold-distributed-context - coordinate contracts across repositories
- upstream tdd - drive deterministic seams from behavior
1---2name: build-autonomous-agents3description: Designs and implements bounded autonomous agent systems for product features and software or product SDLC automation with runtime-neutral contracts. Use when building an agent, finite workflow, subagent, scheduled or overnight job, CI agent, chat or channel integration, observable agent service, adding Flue to an application, or migrating an older Flue integration.4---56# Build Autonomous Agents78Build the smallest autonomous system that can produce and verify the intended9outcome. Keep the workload contract portable even when Flue is the selected10runtime.1112## 1. Ground the Workload1314Read the target's instructions, domain context, architecture, tests, delivery15controls, security boundaries, and existing runtime integration.1617State:1819- the user or operational outcome20- whether the workload is a product capability or SDLC automation21- trigger, owner, input, output, and completion condition22- allowed data, tools, repositories, network access, secrets, and side effects23- required human approval, cancellation, and rollback points2425First test whether deterministic code, an existing application service, a26script, or a CI job can solve the problem. Do not add an agent when those are27sufficient.2829## 2. Select the Smallest Unit3031| Need | Unit |32|---|---|33| Deterministic operation | Function or application service |34| Bounded capability the model may call | Tool |35| Reusable application-controlled orchestration | Action |36| Finite inspectable operation | Workflow |37| Continuing stateful interaction | Agent |38| Focused separable responsibility | Subagent |3940Use a subagent only when its independent context, tools, or evaluation boundary41improves the result enough to justify delegation.4243## 3. Write the Execution Contract4445Define before implementation:4647- validated input and output schemas48- model-visible context, Skills, and tools49- deterministic validation and application of results50- work identity, deduplication key, state owner, and retention51- isolation and permission boundary52- timeout, token or spend budget, concurrency, and stop condition53- retry, idempotency, recovery, duplicate-effect handling, and failure owner54- durable checkpoint, next wake condition, progress deadline, and reconciliation55- eval cases, telemetry, alerts, and incident owner5657Separate probabilistic judgment from deterministic effects. Prefer a typed58proposal that application code validates and applies over letting model output59mutate business state directly.6061## 4. Select and Verify the Runtime6263Use the target's existing runtime when it meets the contract. For a TypeScript64system that needs a harness-first agent runtime, Flue is the current default65candidate, not part of the product contract.6667Before adopting or changing Flue:68691. Detect the installed version, package manager, deployment target, and70 existing integration.712. Use the installed CLI's `flue docs search` and `flue docs read` commands72 first because those docs match the installed version.733. Check official upstream docs, changelog, package metadata, and types when74 adopting or upgrading.754. Prefer the latest reviewed stable release. Do not adopt a nightly merely76 because it is newer.775. Read [REFERENCE.md](./REFERENCE.md) for current Flue boundaries and migration78 hazards.7980Do not copy imports from `@flue/runtime/internal`; they are not a portable81public integration boundary.8283## 5. Implement One Vertical Slice8485For a product capability:8687- keep authentication, authorization, business data, provider credentials,88 persistence, and application of results application-owned89- expose meaningful queued, running, review, success, and failure states90- make any consequential result reviewable before application where risk91 requires it9293For SDLC automation:9495- pin the repository revision and use an isolated worktree or sandbox96- grant the minimum repository, network, and secret permissions97- produce a reviewable patch, report, or other bounded artifact98- run the repository's Fast Check and relevant Full Gates99- never merge, deploy, or publish without explicit authority100101Start deterministic seams with a failing behavior test and agent judgment with102a representative failing eval case. Implement the narrowest path from input103through verified outcome before adding channels, schedules, subagents, or104generalized abstractions.105106## 6. Prove Safety and Recovery107108- Treat local host execution as trusted execution, not isolation.109- Keep conversation state, workspace state, and business state distinct.110- Do not assume an interrupted finite workflow resumes at an arbitrary111 TypeScript step.112- Persist every useful increment and the next eligible action outside the live113 model session. Every routine non-terminal state must have a wake condition or114 a reconciler that owns progress; a human prompt is not a scheduler. A required115 human response waits on a durable correlated event with a deadline and116 escalation; it is never inferred or auto-approved.117- Detect expired claims and missed progress deadlines. Inspect retained state118 and external effects before a bounded requeue; alert the named failure owner119 when safe recovery is not possible.120- Put external side effects behind application-owned idempotency keys.121- Use a durable external orchestrator when step-level resumability is required.122- Keep model-visible data, logs, traces, and run history free of unnecessary123 secrets and personal data.124125## 7. Evaluate and Observe126127Test representative success, refusal, malformed output, tool failure, timeout,128retry, duplicate delivery, cancellation, and permission-denied cases. Assert129schemas, tool calls, side effects, latency, and cost where relevant.130131Emit enough structured evidence to answer:132133- what triggered the run134- which version and configuration ran135- what tools and effects occurred136- why it stopped137- whether the outcome passed deterministic checks and evals138139Complete the work only when the bounded outcome works end to end, failure and140recovery behavior is demonstrated, permissions and budgets are explicit, and141the runtime can be replaced without changing the product contract. An idle142system has no admissible signal; a paused, blocked, or partial run exposes its143reason, owner, retained checkpoint, and next wake or escalation condition.144145## Related Skills146147- **scaffold-harness** - assess maturity and runtime need148- **coding-discipline** - implement the smallest safe change149- **completion-gate** - verify before claiming completion150- **product-craft** - define product value and human oversight151- **scaffold-distributed-context** - coordinate contracts across repositories152- upstream **tdd** - drive deterministic seams from behavior