Skip to content

Latest commit

 

History

History
90 lines (62 loc) · 2.55 KB

plan-executor.md

File metadata and controls

90 lines (62 loc) · 2.55 KB

Split planning from doing

The problem

An office sets up a meeting room. It needs chairs, a screen, coffee, name cards and more.

The first try is an agent loop. The model picks one move, reads the result and picks again. Each turn sends the whole history once more.

How it works

Plan all room steps before running them.

Split the work between a planner and an executor.

  1. The planner is one model call. It writes the full list of steps.
  2. Code checks that every step exists before any step runs.
  3. The executor is plain code. It runs the steps in order.
  4. The planner is asked again only when a step fails.

For example, the projector is broken. The planner is told and picks another screen.

The flow

sequenceDiagram
    participant Office as Your code
    participant Model
    Office->>Model: write all the steps
    Model-->>Office: plan
    alt a step does not exist
        Office->>Model: fix the plan
    else a step fails while running
        Office->>Model: plan the rest
    else all steps work
        Office->>Office: room is ready
    end
Loading

Concepts

Run it

uv run lab plan-executor naive
uv run lab plan-executor

Add --case 2 or --case 3 to try the other cases.

Prove it

There are three rooms with one broken screen each. Code counts input tokens. An unmet need adds a large charge.

Version Tokens read
Agent loop 50,026
Plan, then execute 3,565

Now break it. Open the pattern file and find unknown_steps. Make it return an empty list. Then run the test:

uv run pytest tests/promises/test_plan_executor.py

The test fails, because a plan with a step that does not exist is now run.

Stuck points

  • A "no key found" message means the key file is missing. Copy the example file and paste your key.
  • If you see "so nothing was run", the plan named actions that do not exist.

What to watch for

A fixed plan cannot react to surprises until a step fails. Use an agent loop when each move depends on what you saw last.

Our rooms are a stand in. Your savings depend on how long the loop would run.

Where to go next

Go to Reason with observations. It reads each result before the next move.