Skip to content

feat(delegation): choose a sub-agent's reasoning effort from its roster role (RR8.4) - #201

Merged
lg2m merged 7 commits into
fix/eng-955-rr8-effort-aware-output-capfrom
feat/eng-956-rr8-role-effort
Sep 28, 2026
Merged

lg2m merged 7 commits into
fix/eng-955-rr8-effort-aware-output-capfrom
feat/eng-956-rr8-role-effort

Conversation

@lg2m

@lg2m lg2m commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

RR8.4: per-role reasoning effort for sub-agents

Spec: docs/plans/run-reliability.md (RR8) Linear: ENG-956 Stack: 4/4, on ENG-955

What changed

  • Children no longer inherit the parent's effort pin verbatim. qq_protocol::child_reasoning_effort(entry, parent): an explicit roster effort wins; otherwise fast → low, balanced → medium, each capped by the parent's own pin (a child never thinks harder than the run that delegated to it); strong inherits.
  • resolve_delegation_route returns the chosen effort with the route; SpawnRequest/ChildAdmission carry it; create_child_run writes it to the child's session row in the creation transaction (COALESCE(?17, parent's)), so the loader, replay and clients agree.
  • Config: delegation.roster[].effort. Protocol: optional DelegationRosterEntry.effort (additive, skip_serializing_if; wire goldens unchanged, PROTOCOL_VERSION unchanged). Plan descriptor DESCRIPTOR_VERSION 10 → 11.
  • When the root builds the roster from a known catalog entry, a derived effort is fitted to the route (non-reasoning model → default, i.e. nothing sent; a ladder lacking the level → the highest rung at or below it), so a default role never makes its child unspawnable.
  • The deprecated worker_model is a balanced roster entry and runs at medium like one; audits inherit.
  • Motivation: the audited failing run was a read-only review child at effort: max spending ~14 k reasoning tokens per read_file turn.

How verified

  • child_effort_derives_from_the_role_and_never_exceeds_the_parent
  • a_balanced_child_of_a_max_effort_parent_is_admitted_at_medium (session-level: parent pinned max via SetSessionEffort, child PromptQueued summary shows medium)
  • delegation_route_resolution_prefers_model_then_role_then_default extended; config round-trip in delegation_roster_layers_validates_…
  • Wire/headless goldens and descriptor fixtures pass unchanged.

Docs

  • docs/design/architecture.md § delegation; docs/guide/configuration.md § delegation; ledger docs/plans/progress/run-reliability.md.

Compatibility

  • Protocol: additive optional field, PROTOCOL_VERSION unchanged (30). Descriptor: version 11; roster serialization gains effort only when set. Schema: none.

Evidence

Operator store, read-only: two provider_output_truncated runs on litellm/us.anthropic.claude-fable-5-1 (2026-09-23, 2026-09-25). Every failing turn persisted assistant_content_json = [] with output_tokens = 16384; every continuation request had input_tokens = 2 uncached (byte-identical resend). Route-wide since 09-10: 3 935 turns, 49 truncated, 31 empty, ≈ 671 k output tokens and ≈ 2 h wall producing nothing.

Review round (Codex)

  • Fixed: DESCRIPTOR_VERSION 10 → 11 (feat(mcp)!: pin MCP tool sets in config and plan identity; enforce at dispatch; add qq mcp inspect #194 took v10 for MCP pins; digest domain, golden digest, and the mutation test cover delegation.roster[].effort).
  • Fixed: a role-derived effort ignored the child route's ladder (fast → a non-reasoning model sent an effort the provider rejects; balanced → a [low, high] route failed admission at medium). The root now fits a derived effort to the catalog entry when building the roster; explicit entry efforts are unchanged. Test: a_derived_roster_effort_is_fitted_to_the_child_route.
  • Declined (round 3): fitting the roster effort against the discovery cache (the roster is built from the static catalog everywhere; an explicit entry effort covers a discovered-only route); an ADR for the descriptor bump (an optional field that is None for every existing config is not a behavioural identity change); reasoning_efforts declared without reasoning: true (contradictory config; validation if anywhere).
  • Docs: worker_model is a balanced roster entry and runs at medium like one; the "inherits as before" wording was wrong and is corrected. Audits still inherit.

Gates (run on the stack tip and on this branch's tip)

  • cargo fmt --all -- --check ✅
  • cargo clippy --workspace --all-targets --all-features -- -D warnings ✅ (every branch tip)
  • cargo test --workspace ✅ all passing at the stack tip; each intermediate tip compiles and passes qq/qq-core/qq-provider on its own.
  • cargo test -p qq-provider --no-default-features --features test-support ✅ 184 passed.
  • wasm32 qq-client build ✅

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T05:16:41.284734Z 10d1163 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lg2m
lg2m added this pull request to stack #202 September 26, 2026 06:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14a60e6ab7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/qq-protocol/src/capabilities.rs Resolved
Comment thread crates/qq-config/src/document.rs Resolved
Comment thread crates/qq-protocol/src/capabilities.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7dd07916d0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/runtime.rs
Comment on lines +3166 to +3167
} else if ladder.is_empty() || ladder.contains(&derived) {
Some(derived)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve provider-default effort for unsupported adapters

Fresh evidence after the earlier worker-model comment: this new empty-ladder branch assigns low/medium to Bedrock and Bedrock Mantle roster entries, even though their catalog ladders are intentionally empty because ResolvedModel.generation.reasoning_effort is Unsupported for non-HTTP access and both adapters reject any concrete effort. Consequently, the default balanced roster entry—including one synthesized from legacy worker_model—fails child preflight with UnsupportedReasoningEffort instead of spawning. Treat an empty ladder on an effort-unsupported route as Default rather than as permission to use the derived value.

Useful? React with 👍 / 👎.

Comment thread src/runtime.rs
.copied()
.filter(|level| rank(*level) <= derived_rank)
.max_by_key(|level| rank(*level))
.or_else(|| ladder.iter().copied().min_by_key(|level| rank(*level)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not raise children above the parent's effort ceiling

When the derived ceiling is below every advertised rung, this fallback selects the route's lowest rung even though it is higher than the parent. For example, a minimal parent delegating to a [low, high] route derives minimal but is rewritten to low, violating the stated invariant that a child never thinks harder than its parent; the same fallback also rewrites a strong parent's explicit default to the lowest rung because Default has no rank. Preserve provider default or reject the spawn when no advertised level satisfies the ceiling instead of falling upward.

Useful? React with 👍 / 👎.

route: ModelRoute,
role: DelegationRole,
note: Option<String>,
effort: Option<qq_provider::ReasoningEffort>,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Expose roster effort in config show

Adding DelegationEntry::effort without updating print_snapshot leaves qq config show unable to display the effective value: src/main.rs:1123-1131 prints each roster entry's route, role, and note only. Thus configurations that explicitly pin effort: high produce the same inspection output as configurations that derive effort from the role, which is especially misleading when diagnosing child cost or admission failures. Include the explicit effort, or a clear derived marker, in each printed delegation entry.

Useful? React with 👍 / 👎.

Comment on lines 254 to +258
pub note: Option<String>,
/// The reasoning effort children spawned on this entry run at. `None`
/// derives one from the role: `fast` → low, `balanced` → medium, never
/// above the parent's own effort; `strong` inherits the parent's.
#[serde(default, skip_serializing_if = "Option::is_none")]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Document effort in the capabilities wire contract

This adds effort to the externally serialized delegation roster, but docs/design/protocol.md:539-550 still defines every advertised roster-entry field without mentioning it or its derived-role semantics. Clients implementing the capabilities contract therefore cannot tell that the optional value is behavior-affecting, how None is interpreted, or why the server may return a concrete derived value even when configuration omitted one. Amend the protocol design alongside this wire-field addition.

AGENTS.md reference: AGENTS.md:L205-L210

Useful? React with 👍 / 👎.

@lg2m
lg2m force-pushed the feat/eng-956-rr8-role-effort branch from 7dd0791 to 97ed7af Compare September 26, 2026 19:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 97ed7afa02

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/runtime.rs Resolved
Comment thread crates/qq-core/src/plan/descriptor.rs Resolved
Comment thread src/runtime.rs Resolved
@lg2m
lg2m force-pushed the feat/eng-956-rr8-role-effort branch 2 times, most recently from 4cb21df to 194a765 Compare September 26, 2026 20:04

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 194a7653a9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/design/architecture.md Resolved
…er role (RR8.4)

Children inherited the parent session's effort pin verbatim, so a read-only
review worker under `max` spent ~14 k hidden reasoning tokens per read_file
turn (the audited 33-minute run). The effort is now chosen at spawn from the
roster entry the call resolved through: an explicit `effort` on the entry
wins; otherwise fast → low and balanced → medium, each capped by the parent's
own pin, and strong inherits. The chosen value is written to the child's
session row in the creation transaction so the loader, replay and clients
agree. Legacy worker-model spawns and audits inherit as before.

Config: `delegation.roster[].effort`. Protocol: `DelegationRosterEntry.effort`
(optional, additive; goldens unchanged) and `child_reasoning_effort`.

Tests: child_effort_derives_from_the_role_and_never_exceeds_the_parent,
a_balanced_child_of_a_max_effort_parent_is_admitted_at_medium,
roster effort round-trip in delegation_roster_layers_validates_….

Linear: ENG-956
…an descriptor to v11 (RR8.4 review)

A role-derived effort (fast → low, balanced → medium) ignored what the child's
route accepts: `fast` onto a model without reasoning sent an effort the
provider rejects, and `balanced` onto a route advertising only `[low, high]`
failed admission as ReasoningEffortNotAdvertised. When the root builds the
roster from a catalog it knows, a derived effort is now fitted first: a model
without reasoning takes `default` (nothing sent) and a ladder lacking the level
yields the highest rung at or below it. An explicit entry effort is untouched
and validated at the child's load as before. Test:
a_derived_roster_effort_is_fitted_to_the_child_route.

`DelegationRosterEntry.effort` changed the descriptor's canonical bytes without
the version bump the module requires: DESCRIPTOR_VERSION 10 → 11 (#194 took
v10 for MCP pins), digest domain and golden re-pinned, `delegation.effort`
added to the mutation test.

Docs: `worker_model` is a balanced roster entry and runs at medium; the text
claiming it "inherits as before" was wrong. Ledger records the review round.

Linear: ENG-956
@lg2m
lg2m force-pushed the feat/eng-956-rr8-role-effort branch from 194a765 to 10d1163 Compare September 28, 2026 05:13
@lg2m
lg2m merged commit 1e91895 into main Sep 28, 2026
10 of 12 checks passed
@lg2m
lg2m deleted the feat/eng-956-rr8-role-effort branch September 28, 2026 05:16
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