Skip to content

core: keep parent-visible subagent context current - #615

Merged
GraciousGazelles merged 14 commits into
mainfrom
fix/history-successor-subagent-context-main-ad234-sharedlint
Aug 14, 2026
Merged

GraciousGazelles merged 14 commits into
mainfrom
fix/history-successor-subagent-context-main-ad234-sharedlint

Conversation

@GraciousGazelles

@GraciousGazelles GraciousGazelles commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Parent-visible environment context could retain stale subagent information after a child changed or disappeared. That made resumed or compacted turns describe an outdated set of active subagents.

What changed

  • Build bounded, deterministic context from currently loaded direct child agents.
  • Normalize and XML-escape model-visible fields, with row and byte limits.
  • Emit the current bounded snapshot when subagents change.
  • Emit an explicit unavailable marker when previously visible subagents disappear.
  • Avoid redundant context when the visible state is unchanged.
  • Avoid copying an unbounded task name before bounded rendering.
  • Add focused coverage for rendering, bounds, production child metadata, changes, removals, and unchanged state.
  • Apply the follow-up lint fixes for bounded XML rendering and direct row assembly.

Validation

Exact candidate: 4a0cfdea8ff85bb4a2f415c501fc65fb12ba2491

The successful PR-triggered heavy run 31828100781 is intentionally excluded from exact-head acceptance evidence because its summary artifact records the synthetic PR merge ref instead of the candidate head. A separate follow-up covers the workflow-summary head-binding issue.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a structured SubagentContext and SubagentContextBuilder to safely format, escape, and limit subagent context data, replacing the previous simple string formatting. It also updates the environment state rendering to support subagent updates and unavailability, backed by comprehensive unit tests. The review feedback focuses on performance optimizations, specifically recommending the elimination of unnecessary string allocations in bounded_xml_text by using a stack-allocated buffer with char::encode_utf8, and in SubagentContextBuilder::finish by building the final string directly instead of collecting rows into a temporary vector.

@GraciousGazelles
GraciousGazelles added this pull request to the merge queue Aug 14, 2026
Merged via the queue into main with commit 285f56b Aug 14, 2026
146 checks passed
@GraciousGazelles
GraciousGazelles deleted the fix/history-successor-subagent-context-main-ad234-sharedlint branch August 14, 2026 20:55
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