Skip to content

Latest commit

 

History

History
87 lines (60 loc) · 2.6 KB

meta-controller.md

File metadata and controls

87 lines (60 loc) · 2.6 KB

Choose the next agent

The problem

An estate agent writes a property listing. The law asks for some sentences, word for word. Some phrases are banned, and the length has a limit.

The first try runs the same agents in a fixed line. A later agent can undo an earlier one. A listing that breaks a rule can then go out.

How it works

Choose the next agent for a listing.

A controller reads each draft and picks the one agent it needs.

  1. A writer makes the first draft.
  2. Code checks every rule on the draft.
  3. The controller picks the editor, trimmer or legal agent.
  4. It stops when all rules pass, or holds the listing back.

For example, a draft passes every rule except one required sentence. Only the legal agent runs. Nothing else can then cut or change the text.

The flow

sequenceDiagram
    participant Code as Controller
    participant Agent
    participant Site
    Code->>Agent: fix this one problem
    Agent-->>Code: new draft
    alt all rules pass
        Code->>Site: publish
    else the turns run out
        Code->>Code: do not publish
    end
Loading

Concepts

Run it

uv run lab meta-controller naive
uv run lab meta-controller

Add --case 2 up to --case 8 for other homes.

Prove it

There are eight homes, and each one runs three times. Code counts the listings that went out with every rule met. Higher is better. A held listing counts for nothing.

Version Listings out with every rule met
Fixed line of agents 16
Controller picks 24

Now break it. Open the pattern file and find choose. Make it always return nothing to do. Then run the test:

uv run pytest tests/promises/test_meta_controller.py

The test fails, because a draft that breaks a rule now goes out.

Stuck points

  • A "no key found" message means the key file is missing. Copy the example file and paste your key.
  • No listing in the outcome means it never passed. The code held it on purpose.

What to watch for

Results change from run to run, and a single run can come out level. A held listing still needs a person to finish it. The controller here is plain code, which is enough when rules are clear.

Where to go next

Go to Coordinate through neighbours. It solves a task with many small neighbours instead of one boss.