Skip to content

feat(runtime): tell sub-agents a parent is waiting and how to answer (AP1) - #235

Merged
lg2m merged 2 commits into
fix/eng-988-ap2-pruned-read-stubfrom
feat/eng-989-ap1-subagent-brief
Oct 2, 2026
Merged

lg2m merged 2 commits into
fix/eng-988-ap2-pruned-read-stubfrom
feat/eng-989-ap1-subagent-brief

Conversation

@lg2m

@lg2m lg2m commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Slice AP1 of autonomous-core.md (ADR-0054 § 5) · Linear ENG-989 · Base: #233 (AP2), on #232.

What changes for users

Sub-agents are told what they are for. Until now a spawned child got the root prompt word for word, including "Implement requested changes rather than stopping at analysis unless the user requested analysis-only work." A child has no user, so the exception never applied, and a read-only child kept reading. Over 30 days of the session store, 30 of 74 children that ran 64 or more calls said nothing until their final turn.

Child task runs now get a Sub-agent: section:

Sub-agent:
- You are a sub-agent. Another agent is waiting for you, and only your final reply reaches it; nothing else you say or read in this run does. Your first message is its brief.
- Stop as soon as you can answer the brief. Do not survey the codebase beyond what the answer needs.
- Reply with the answer first, then the evidence as path:line, then what you could not establish.
- Do not re-read text that is still in your context. Re-read a file only for lines you have not seen or that may have changed.
- You cannot change files or run commands. If the brief asks for a change, answer with what should change and where, and stop.   ← read children only
  • Read children drop the "implement rather than stop" line.
  • Write children (supervised) keep it.

Parents get one new delegation bullet, and the spawn_agent task description now asks for the question, what the answer is for, and the answer shape.

Design

  • Keyed on being a child. The section is a new PromptPrefixKey.subagent (Read / Write / none), so a read-only root is unchanged. That case is tested.
  • Detection. A run gets the section when depth > 0, it is not user-initiated, and its purpose is Task (sessions/execution.rs). Excluded:
    • audit children, which keep their fixed JSON brief;
    • a user's own prompt in a child session.
  • Cache. The section is inside the plan-constant prefix, so it is built once per key, hashed once, and cached. The prefix-hasher continuation invariant still holds, and its test passes.
  • Versions. AGENT_PROMPT_VERSION goes 14 → 15. DESCRIPTOR_VERSION is unchanged. The golden descriptor digest moves only because the descriptor embeds the prompt version; the encoding is the same.

Verification

  • New tests:
    • subagent_prompts_say_a_parent_is_waiting_and_read_children_drop_the_implement_line checks that the child prompts differ from the root only by the section and the removed line.
    • a_root_prompt_and_tools_change_only_by_the_brief_guidance is a golden test against version 14 (356092a). With the new bullet removed and the old task text restored, the root prompt and the spawn_agent schema hash to the base values, and every built-in declaration is unchanged. Two planted one-character edits each made it fail.
    • a_read_only_root_keeps_the_implement_line_and_has_no_subagent_section.
    • delegation_guidance_asks_for_a_question_a_purpose_and_an_answer_shape.
  • Assertions added to end-to-end tests:
    • a read child gets the section and loses the implement line, and the user's follow-up in the same session doesn't get the section;
    • a write child gets the section and keeps the line;
    • an audit child gets no section;
    • the parent gets no section.
  • cargo test --workspace on the stacked branch (AP2 + AP1): 2012 passed, 0 failed. Clippy (--all-targets --all-features -D warnings) and fmt are clean.
  • plan_compile, 4 × 2 000 iterations: 24.9–25.2 µs before, 25.0–26.0 µs after, within noise.
  • Independent read-only review: two blocking findings (the missing golden test and the missing root request for architecture.md). Both are fixed in 3376d27.

Compatibility

  • No protocol, descriptor-encoding or store change.
  • Prompt version 15 changes every system-prompt hash once. As with earlier prompt bumps, the first request in each session after an upgrade doesn't reuse its measured occupancy.
  • docs/design/architecture.md describes the new key and the section, with a root request row in progress/root.md.

lg2m added 2 commits October 1, 2026 10:07
A model-spawned child got the root prompt verbatim, including "implement
requested changes rather than stopping at analysis". It has no user, so the
exception never applied and a read child kept reading. Nothing told it that
only its final reply reaches a waiting parent, or when to stop.

Child task runs now get a Sub-agent section: a parent is waiting; stop once
you can answer; answer first, then path:line evidence, then open questions;
do not re-read what is in context. Read children drop the implement-instead
line and are told they cannot change files. The section is keyed in the
prompt-prefix cache by being a child, so a read-only root is unchanged.
Audit children keep their fixed brief and JSON reply, and a user's prompt in
a child session gets the ordinary prompt. The parent's delegation guidance
and the spawn_agent task description ask for a question, a purpose and an
answer shape.

AGENT_PROMPT_VERSION 14 -> 15. DESCRIPTOR_VERSION is unchanged; the golden
digest moves only because the descriptor embeds the prompt version.

AP1 of docs/plans/autonomous-core.md (ADR-0054 § 5).

Linear: ENG-989
… brief guidance

The golden test hashes the root prompt with the new bullet removed, and the
spawn_agent schema with the old task text restored, against 356092a. Two
planted edits made it fail. Adds a read-only root test and the
architecture.md root request (review follow-up).

Linear: ENG-989
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@lg2m
lg2m added this pull request to stack #234 October 1, 2026 22:00
@lg2m
lg2m merged commit 7870b20 into main Oct 2, 2026
4 checks passed
@lg2m
lg2m deleted the feat/eng-989-ap1-subagent-brief branch October 2, 2026 05:26
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