diff --git a/doc/agents/fleet-command-channel.md b/doc/agents/fleet-command-channel.md index 1e8c37f4cd..3d3e60921f 100644 --- a/doc/agents/fleet-command-channel.md +++ b/doc/agents/fleet-command-channel.md @@ -17,12 +17,12 @@ 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 --groups [,] # once per run -fleet bridge inbox --agent --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. - `` 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, @@ -30,8 +30,19 @@ fleet bridge inbox --agent --commands --take - 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 --groups [,] # once per run +fleet bridge inbox --agent --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: diff --git a/scripts/tests/test_lane_prompts_use_agent_next.py b/scripts/tests/test_lane_prompts_use_agent_next.py new file mode 100644 index 0000000000..14ead8f55a --- /dev/null +++ b/scripts/tests/test_lane_prompts_use_agent_next.py @@ -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()