Skip to content

docs(constitution): add anti-polling rule for sub-agent waiting strategy#4098

Open
Mr-Moon121 wants to merge 2 commits into
Hmbown:mainfrom
Mr-Moon121:fix/subagent-anti-polling-constitution
Open

docs(constitution): add anti-polling rule for sub-agent waiting strategy#4098
Mr-Moon121 wants to merge 2 commits into
Hmbown:mainfrom
Mr-Moon121:fix/subagent-anti-polling-constitution

Conversation

@Mr-Moon121

Copy link
Copy Markdown

Problem

When the parent launches sub-agents and runs out of independent work, it falls into a wasteful peek-sleep-peek-sleep polling loop instead of passively waiting for subagent_completion events. This burns turns and budget without changing the outcome (sub-agents don't finish faster because you poll them).

Evidence: issue #4097 documents a real session where 3 sub-agents triggered 13 peek calls and 5 artificial sleep calls (140s blocked), with $0.086 sub-agent cost where the majority was polling overhead.

Solution

Add explicit "Waiting, not polling" guidance to the Sub-Agent Strategy section in constitution.md:

  • Do not poll with peek or status actions
  • Do not use sleep as a wait primitive
  • If the runtime gives you a new turn with no new user message and children are running: stop immediately, emit zero tool calls, end the turn

The runtime already delivers subagent.done sentinels as user messages when children complete. Polling is pure waste.

Change

One file: crates/tui/src/prompts/constitution.md — new bullet in the Sub-Agent Strategy section.

Closes #4097

When the parent launches sub-agents and runs out of independent work,
it currently falls into a wasteful peek+sleep polling loop instead of
passively waiting for subagent_completion events. This burns turns
and budget without changing the outcome (sub-agents don't finish
faster because you polled them).

Add explicit 'Waiting, not polling' guidance to the Sub-Agent Strategy
section: do not poll with peek/status, do not use sleep as a wait
primitive, and if the runtime gives you a new turn with no user message
while children are running, stop immediately.

Closes Hmbown#4097
@Mr-Moon121 Mr-Moon121 requested a review from Hmbown as a code owner July 7, 2026 19:20
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Thanks @Mr-Moon121 for taking the time to contribute.

This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered.

Please read CONTRIBUTING.md for the expected contribution shape. A maintainer can grant recurring PR access by commenting /lgtm on a pull request.

…agents

When the parent turn ends because it has no independent work left but
sub-agents are still running, inject a runtime event telling the model
to wait passively instead of polling with peek/status/sleep.

This is the runtime-side complement to the constitution.md anti-polling
rule. Together they form a two-layer defense against the wasteful
polling loop documented in Hmbown#4097.

Refs: Hmbown#4097
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.

v0.8.67: Parent model burns turns with peek+sleep polling loop while waiting for sub-agent completion — #3183 regression

1 participant