[PR #10539] fix(questions): fixes #7654 where sub-sub agents can't ask questions #13476

Open
opened 2026-02-16 18:18:19 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10539

State: open
Merged: No


Summary
Fixes issue https://github.com/anomalyco/opencode/issues/7654 where questions from deeply nested sub-agents (grandchildren and beyond) don't appear in the main session's TUI.

The root cause was that the TUI only collected questions from direct children sessions, missing grandchildren spawned via background_task or other nested agent mechanisms. This PR implements recursive descendant collection to ensure all questions from the entire session tree are visible.

Changes
Core Implementation
Added recursive descendant collection (descendants() memo) that traverses the entire session tree
Updated permissions and questions collection to use descendants() instead of children()
Included circular reference protection with a visited Set to prevent infinite loops
Preserved backward compatibility by keeping the children() memo unchanged
Testing
4 comprehensive integration tests covering:
Grandchild questions appearing in list (core fix validation)
Questions from multiple nesting levels coexisting
Deep hierarchies (4+ levels)
Session parent-child relationships
Stages Completed
Stage 1/3: [Implement Recursive Descendant Collection]4)

Added descendants() memo with recursive tree traversal
Updated permissions() and questions() to use descendants
Included circular reference protection
Stage 2/3: Add Circular Reference Protection (included in Stage 1)

Visited Set prevents infinite loops
Handles circular references, self-references, and diamond patterns
Stage 3/3: [Testing and Validation]

Created integration tests for nested question visibility
Verified fix works across various nesting scenarios
Testing
TypeScript compilation passes (bun typecheck)
Integration tests created and structured correctly
All existing behavior preserved (backward compatible)
Code follows repository style guide

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10539 **State:** open **Merged:** No --- Summary Fixes issue https://github.com/anomalyco/opencode/issues/7654 where questions from deeply nested sub-agents (grandchildren and beyond) don't appear in the main session's TUI. The root cause was that the TUI only collected questions from direct children sessions, missing grandchildren spawned via background_task or other nested agent mechanisms. This PR implements recursive descendant collection to ensure all questions from the entire session tree are visible. Changes Core Implementation Added recursive descendant collection (descendants() memo) that traverses the entire session tree Updated permissions and questions collection to use descendants() instead of children() Included circular reference protection with a visited Set to prevent infinite loops Preserved backward compatibility by keeping the children() memo unchanged Testing 4 comprehensive integration tests covering: Grandchild questions appearing in list (core fix validation) Questions from multiple nesting levels coexisting Deep hierarchies (4+ levels) Session parent-child relationships Stages Completed ✅ Stage 1/3: [Implement Recursive Descendant Collection]4) Added descendants() memo with recursive tree traversal Updated permissions() and questions() to use descendants Included circular reference protection ✅ Stage 2/3: Add Circular Reference Protection (included in Stage 1) Visited Set prevents infinite loops Handles circular references, self-references, and diamond patterns ✅ Stage 3/3: [Testing and Validation] Created integration tests for nested question visibility Verified fix works across various nesting scenarios Testing TypeScript compilation passes (bun typecheck) Integration tests created and structured correctly All existing behavior preserved (backward compatible) Code follows repository style guide
yindo added the pull-request label 2026-02-16 18:18:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13476