Skip to content

Let invoke_planner start an automatic follow-up behind a system notice - #667

Merged
lavaman131 merged 1 commit into
mainfrom
planner-system-turns
Oct 18, 2026
Merged

lavaman131 merged 1 commit into
mainfrom
planner-system-turns

Conversation

@lavaman131

Copy link
Copy Markdown
Collaborator

An attached Planner client or an MCP caller sometimes needs a Planner turn that nobody typed, such as "a workflow run finished; update the document". Until now invoke_planner could only post the instruction as the caller's member message.

What changes

invoke_planner takes an optional as: "system":

{
	"id": "/documents/octo-org/score/release-readiness",
	"instruction": "The workflow run finished. Read its results and update the document.",
	"as": "system"
}
  • The turn goes through the existing instruct() path. Chat shows the system notice Automatic follow-up requested by @login. instead of a member message. The instruction reaches the Planner alone, and it stays out of the visible queue while it waits.
  • Only the document's creator, or the account whose client holds its Planner, may send one. Anyone else gets system-turn-forbidden. For a child document, the check uses its root.
  • Each document accepts at most 10 per hour, counted in memory. Past that, the call gets system-turn-limited. A follow-up that is refused later (for example planner-not-attached) does not use up the limit.
  • Every accepted or refused follow-up is logged.
  • Ordinary invoke_planner calls and every other refusal behave as before. Nothing changes in the agent-connection protocol: an attached client calls invoke_planner with a GitHub token of the account that holds the Planner.

Docs: local-agent-mcp.md ("Automatic follow-ups"), hosted-agent.md, agent-connection.md, authentication.md, AGENTS.md.

Verification

  • New unit tests in apps/server/src/mcp/invoke.test.ts, written to fail first, cover:
    • a system turn starts with the instruction and shows only the notice
    • a queued system turn stays out of the queue frames
    • non-owners are refused, and the Planner's holder is allowed
    • the hourly limit, and that ordinary calls don't count against it
    • argument validation and the new refusal codes
  • hosted.test.ts checks that as: "system" reaches the invocation.
  • bun test apps/server packages apps/web: 5790 pass, 0 fail. bun run types and bun run ci pass.
  • Browser: mcp-update, planner-attachment, and chat-mentions e2e pass (13 tests).

An attached Planner client or an MCP caller sometimes needs a Planner turn
nobody typed, such as updating the document after a workflow run finishes.
invoke_planner now takes an optional as: "system". The turn goes through
instruct(), so Chat shows "Automatic follow-up requested by @login." instead
of the caller's member message, and the instruction reaches the Planner
alone, also kept out of the visible queue while it waits.

Only the document's creator, or the account whose client holds its Planner,
may send one (system-turn-forbidden otherwise), and each document takes at
most 10 an hour (system-turn-limited). Accepted and refused follow-ups are
logged. An ordinary invoke_planner call is unchanged.

Assistant-model: Claude Opus 5.5 (fast)
Assistant-workflow: inline (fast subagents)
Assistant-verification: unit tests for the system turn, its notice, owner refusal, hourly limit and argument validation, written failing first
Assistant-verification: full server, package and web unit suites, type checks and lint/format checks pass
Assistant-verification: MCP, Planner attachment and chat mention browser tests pass
Co-authored-by: Alex Lavaee <alexlavaee@microsoft.com>
@lavaman131 lavaman131 self-assigned this Oct 17, 2026
@lavaman131
lavaman131 merged commit 526702a into main Oct 18, 2026
24 checks passed
@lavaman131
lavaman131 deleted the planner-system-turns branch October 18, 2026 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant