Skip to content

Learning: Single Agent Workflows

How to Use This Page

  • Keep each loop step observable.
  • Stop on evidence, not intuition.
  • Track both quality and cost per run.

Lesson 1: Fundamentals

Learn the plan -> act -> observe loop and why explicit loop state matters.

What You Learn

  • How to separate planning from action execution
  • Why observation logs improve final answer quality
  • How step limits prevent runaway loops

Walkthrough

  1. Build a loop with explicit plan, action, and observation fields.
  2. Run for a fixed maximum step count.
  3. Produce a final answer from accumulated evidence.

Try It Yourself

  • Remove observation tracking and compare output quality.
  • Test step limits of 3, 5, and 8.
  • Add a guard for repeated actions.

Lesson 2: Intermediate Patterns

Learn evidence sufficiency checks and fallback behavior.

What You Learn

  • How to determine when evidence is "enough"
  • Why repeated low-yield steps should trigger fallback
  • How confidence notes improve answer transparency

Walkthrough

  1. Add an evidence scoring rule.
  2. Stop when score crosses threshold.
  3. Route low-score runs to fallback response logic.

Try It Yourself

  • Compare strict vs lenient evidence thresholds.
  • Add a fallback that requests clarification from the user.
  • Log how often fallback is triggered.

Lesson 3: Production Patterns

Learn adaptive planning and information-gain-driven stopping.

What You Learn

  • How to estimate per-step information gain
  • Why early stopping can reduce cost without quality loss
  • How to escalate uncertain results safely

Walkthrough

  1. Score expected gain for candidate next actions.
  2. Select highest-gain action first.
  3. Stop when expected gain falls below threshold.

Try It Yourself

  • Compare fixed-plan vs adaptive-plan loop performance.
  • Measure cost savings from early stopping.
  • Add an escalation path for uncertain final outputs.

Code Examples

  • Starter script: docs/starter/stage05_single_agent.py
  • Stage architecture notes: docs/roadmap/stage-05-planner-executor-loops/architecture.md