ENع
PHASE 3 — DAY 09

Reliable Workflow Orchestration

Connect bounded steps only when decomposition improves control, then make every handoff observable, repeatable, and safe to stop.

SELF-PACED LABLOCAL SIMULATIONADVANCED

More agents do not imply better results. Every model call adds latency, cost, failure modes, and another place where untrusted content can influence the workflow. Prefer one bounded step or deterministic code unless a measured eval shows that separation improves the required outcome.

Part 1: Start With the Simplest Architecture

1
Deterministic program — use for validation, calculations, routing rules, formatting, permissions, and state changes.
2
Single model step — use for one narrow language task with structured input and output.
3
Multiple model steps — consider only when tasks need different context or evaluation and the handoffs can be validated.

Document the reason for each boundary. “Research,” “draft,” and “review” are not automatically separate agents. A review step that sees the same prompt and shares the same weaknesses may add confidence without adding independent evidence.

Part 2: Make Handoffs Typed and Minimal

Each step gets the minimum information it needs. Define a versioned schema, reject unknown or missing required fields, and treat text from earlier steps as untrusted data rather than instructions.

Handoff contract
Review this proposed workflow as a hostile interface designer. Do not run it. For every handoff: - Draft a strict, versioned JSON schema with size and enum limits. - Identify fields that contain untrusted text and ensure they cannot become instructions. - Minimize personal or confidential data. - Define deterministic validation and an explicit rejection response. - Name the owner who can approve progression. Then challenge whether each model step is needed. Recommend deterministic code or a single-step design where it is sufficient.

Part 3: Design State and Idempotency

A workflow needs an explicit state machine such as RECEIVED, VALIDATED, DRAFTED, AWAITING_APPROVAL, APPROVED, REJECTED, and FAILED. Only defined transitions are allowed. A model must not decide that its own output is approved.

Assign an idempotency key to the run and any proposed side effect. Replaying the same request should return the recorded result or a safe conflict, not duplicate an action. Store checkpoints so a retry resumes from a known state rather than repeating completed work.

Retry rule

Retry only errors classified as transient, use capped attempts and backoff, and preserve the same idempotency key. Validation failures, denied permissions, policy failures, and ambiguous outputs are not retry candidates. They stop for review.

Part 4: Put Human Gates Before Consequences

The lab must not send, publish, purchase, delete, change access, modify budgets, or update a system of record. It may prepare a proposal containing the intended action, target, diff, evidence, uncertainty, and rollback steps. A separately authenticated human approves or rejects that proposal through a channel the model cannot impersonate.

A
What — exact change, destination, and affected records.
B
Why — source evidence, policy basis, and uncertainty.
C
Bounds — volume, cost, time, access scope, and expiry.
D
Recovery — stop control, rollback, incident owner, and audit record.

Part 5: Log Events, Not Payloads

Record correlation ID, component version, schema version, state transition, tool name, target category, decision, error code, latency, and cost. Minimize or redact payload contents. Never place credentials, authentication headers, full personal records, or sensitive prompt text in logs. Protect log access, define retention, and test redaction.

Part 6: Test Failure Before Success

Build a versioned eval set with representative synthetic cases and adversarial cases: prompt injection inside a field, oversized input, wrong schema version, duplicate event, timeout, unavailable dependency, partial output, unauthorized destination, and a request beyond the cost cap.

1
Correctness — predefined expected outputs or a documented reviewer rubric.
2
Safety — denied action remains denied even when the input asks otherwise.
3
Recovery — stop and replay do not lose state or duplicate effects.
4
Operations — latency, token or request cost, and alert behavior stay within project-specific caps.

Part 7: Build a No-Effect Simulation

Connect two steps from Day 8 in the local lab: deterministic input validation followed by a draft generator. The final component validates the draft and writes an approval envelope to output/pending-review.json. It must not execute the proposed action. Run the eval set, interrupt a run midway, replay the same idempotency key, and confirm the state and output remain consistent.

Day 9 Completion Checklist

Complete before moving on
← Day 8: Build a Guarded Workflow Day 10: Readiness Review →