Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions doc/agents/fleet-command-channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,32 @@ section by hand. Enrolment and the full ladder:

## Every lane run (Muse lanes and any other fleet agent)

At the start of each run, before claiming queue work:

```bash
fleet bridge hello --agent <lane> --groups <surface>[,<more>] # once per run
fleet bridge inbox --agent <lane> --commands --take
```
At the start of each run, take work with `fleet agent next`: it checks
the mailbox, then the queue, the host's shortlist and GitHub priority, in
that order, and returns one task with the commands to run when it is done
([onboarding](onboarding-an-agent.md)). Run its `then` lines when the
task is done. Do not run the mailbox and claim steps by hand — that is
what `next` is for.

- `<lane>` is the lane's own stable name (`muse-3`, `oc-go-1`, ...), the
same name the queue claim uses as worker or lane. Lowercase, letters,
digits, `.`, `_`, `-`.
- Groups say who you are for "all of a kind" sends: `muse` for Muse
lanes, `opencode` for OpenCode lanes, `laptop` for laptop jobs.
`hello` replaces the group list, so pass every group each time.
- `--take` marks what it returns as read, so two runs of the same lane
never both act on one command.

### By hand, only when `fleet agent next` cannot run

On a seat whose installed binary predates `fleet agent`, run the mailbox
check yourself at the start of each run, before claiming queue work:

```bash
fleet bridge hello --agent <lane> --groups <surface>[,<more>] # once per run
fleet bridge inbox --agent <lane> --commands --take
```

`--take` marks what it returns as read, so two runs of the same lane
never both act on one command.

For each command returned, in id order:

Expand Down
58 changes: 58 additions & 0 deletions scripts/tests/test_lane_prompts_use_agent_next.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python3
"""Lane prompts call `fleet agent next` instead of hand-written mailbox
and claim steps (issue #12236, item 1).

Oracle: the in-repo lane-run docs prescribe `fleet agent next` as the
first step of a run, with the hand-written `fleet bridge hello` /
`inbox` / queue-claim steps kept only as the fallback for seats whose
binary predates `fleet agent`. A doc that teaches the manual steps first
is a regression: lanes claim from the queue only and never reach the
push, shortlist or priority rungs.
"""

import unittest
from pathlib import Path

ROOT = Path(__file__).resolve().parents[2]
CHANNEL = ROOT / "doc" / "agents" / "fleet-command-channel.md"
ONBOARDING = ROOT / "doc" / "agents" / "onboarding-an-agent.md"
NEXT_WORK = ROOT / ".agents" / "skills" / "next-work" / "SKILL.md"


def section(text, heading):
start = text.index(heading)
rest = text[start + len(heading):]
end = rest.find("\n## ")
return rest if end == -1 else rest[:end]


class LanePromptsUseAgentNextTests(unittest.TestCase):
def test_command_channel_run_starts_with_agent_next(self):
text = CHANNEL.read_text()
run = section(text, "## Every lane run")
first_next = run.index("fleet agent next")
first_manual = min(
run.index("fleet bridge hello"),
run.index("fleet bridge inbox"),
)
self.assertLess(
first_next,
first_manual,
"the lane run must reach `fleet agent next` before any "
"hand-written mailbox step",
)

def test_command_channel_manual_steps_are_fallback_only(self):
text = CHANNEL.read_text()
run = section(text, "## Every lane run")
self.assertIn("By hand, only when `fleet agent next` cannot run", run)

def test_onboarding_prescribes_agent_next(self):
self.assertIn("fleet agent next", ONBOARDING.read_text())

def test_next_work_skill_prescribes_agent_next(self):
self.assertIn("fleet agent next", NEXT_WORK.read_text())


if __name__ == "__main__":
unittest.main()