feat: role-aware sub-agent prompting (built-in contract + per-tier appends) - #151
Merged
Conversation
hallerite
force-pushed
the
feat/subagent-append-prompt
branch
from
August 27, 2026 10:06
38966d2 to
203b511
Compare
hallerite
force-pushed
the
feat/subagent-append-prompt
branch
from
August 27, 2026 10:22
203b511 to
c37465e
Compare
hallerite
marked this pull request as ready for review
August 27, 2026 10:50
hallerite
force-pushed
the
feat/subagent-append-prompt
branch
from
August 27, 2026 10:51
c37465e to
90658c1
Compare
hallerite
force-pushed
the
feat/subagent-append-prompt
branch
from
August 27, 2026 15:58
8d89117 to
50aaef0
Compare
hallerite
force-pushed
the
feat/subagent-append-prompt
branch
from
August 28, 2026 12:59
c08032f to
9059b73
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9059b73. Configure here.
hallerite
force-pushed
the
feat/subagent-append-prompt
branch
2 times, most recently
from
August 28, 2026 14:08
7d97749 to
ec8b5dd
Compare
This was referenced Aug 28, 2026
hallerite
force-pushed
the
feat/subagent-append-prompt
branch
from
August 30, 2026 13:51
ec8b5dd to
09e24c9
Compare
hallerite
force-pushed
the
feat/execution-guardrails
branch
5 times, most recently
from
September 1, 2026 17:46
f693220 to
546b915
Compare
hallerite
force-pushed
the
feat/subagent-append-prompt
branch
2 times, most recently
from
September 1, 2026 20:31
00abb75 to
b23e26a
Compare
RuntimeConfig gains optional subagent_append_to_system_prompt (nodes that can still recurse) and leaf_append_to_system_prompt (depth == max_depth), resolved by depth in resolved_append_to_system_prompt with each tier falling back to the next-more-general one (leaf -> subagent -> root). Wired through the ACP runtime contract; children inherit via model_copy and resolve their own tier.
…pth-gated) Any depth>0 engine opens with its sub-agent identity in the role line (single delegated task, caller sees none of the work) and carries the final-message contract in the final-answer line (self-contained result plus evidence), instead of a separate mid-prompt block that gave the prompt two competing "You are" statements. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
hallerite
force-pushed
the
feat/subagent-append-prompt
branch
from
September 1, 2026 21:04
b23e26a to
b613661
Compare
samsja
added a commit
that referenced
this pull request
Sep 3, 2026
…ation off) Deploy tip (not for merge), rebuilt on current main (post #147/#151/#158/#160/#168 — main takes precedence everywhere): - default system prompt = the validated glm_minimal profile (system_prompt_path and append_to_system_prompt from the ACP contract still take precedence / apply on top; the composed builder remains available as _load_system_prompt_built) - tool-output truncation off unless policy.max_tool_output_bytes is set - prompts/glm_minimal.txt + README (validation numbers) Pin this commit for the GLM-5.3 syngen configuration; everything else is stock main (skills tooling default, compaction + guardrails per #158/#168).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Recursive sessions currently prompt every engine identically: a depth-3 leaf gets the same system prompt as the root, and a single
append_to_system_promptapplies at every depth. This PR makes prompting role-aware, in two layers.What this adds
1. A built-in sub-agent framing, gated on depth (zero config).
build_system_promptnow takesdepth; anydepth>0engine gets its sub-agent identity woven into the prompt's two opening lines instead of the root's plain ones:2. Per-tier append fields (config). The ACP
runtime-v1contract andRuntimeConfiggainsubagent_append_to_system_promptandleaf_append_to_system_promptalongside the existingappend_to_system_prompt.RuntimeConfig.resolved_append_to_system_promptpicks by role, with fallback leaf → subagent → root, so unset fields preserve today's single-append behavior. Children inherit config viamodel_copy, so every descendant resolves its own tier.The resulting tiers:
rlmhintdepth == 0max_depth > 0)append_to_system_prompt1 ≤ depth < max_depthsubagent_append_to_system_promptdepth == max_depthleaf_append_to_system_promptRationale
The design splits sub-agent prompting into three concerns, each handled where it belongs:
rlmrecursion hint; leaves get no mention ofrlmat all. Deliberately no "you cannot spawn sub-agents" line: advertising a missing capability is what caused depth-thrash before this PR — leaves callingrlm(), hitting[depth limit … reached], and burning turns retrying.Before/after on SWE-bench Pro
32 stratified tasks (3 per repo across all 11 repos; identical task list in every arm), k=1, three models via Prime Inference, stock harness settings except
max_depth=1and a 1h rollout wall clock. before = main (7eaff71), after = #151 + #166 stacked (c886994). Zero harness errors across ~190 rollouts.Paired on shared tasks: glm-5.3 3W/0L/29T (sign p=0.25), deepseek 2W/2L/28T, kimi-k3 2W/1L/28T. The after arm is never worse on reward and slightly cheaper on every model (fewer turns and tokens). Individual deltas are within noise at n=32/k=1; the uniform direction across three models is the signal.
One honest caveat for THIS PR: on SWE tasks no model delegates unprompted — exactly one
rlm()call occurred across all ~190 rollouts — so the built-in sub-agent contract almost never rendered and this eval is primarily a no-regression check for it. The contract's behavioral evidence is the append-driven redsearcher experiment above (depth-thrash 13–27 → 0).Note
Medium Risk
Changes affect every agent’s system prompt and runtime contract fields; misconfigured tier appends could alter delegation behavior, though fallbacks preserve prior single-append semantics when new fields are unset.
Overview
This PR makes system prompts depend on where an engine sits in the recursion tree, instead of treating every depth the same.
Built-in sub-agent framing (no config):
build_system_promptnow takesdepthandsession_dir. Engines withdepth > 0get a sub-agent role and a stricter “final answer” line (caller-only, self-contained result with evidence). The conversation log path uses the real session directory when available. Kernel guidance is consolidated intoKERNEL_PACKAGES_PROMPT(!uv pip installin cells); skill help text is slightly tightened.Per-tier config appends: The ACP
runtime-v1contract andRuntimeConfigaddsubagent_append_to_system_promptandleaf_append_to_system_prompt.resolved_append_to_system_promptselects root vs node vs leaf append with fallback leaf → subagent → root, so unset tiers keep today’s single-append_to_system_promptbehavior.RLMEngineapplies the resolved append when loading the system prompt.Kernel bootstrap: IPython startup pre-imports
asyncioso parallelrlmexamples in the prompt work without extra setup.README documents the new append fields and tier semantics.
Reviewed by Cursor Bugbot for commit abc4d2d. Bugbot is set up for automated code reviews on this repo. Configure here.