Skip to content

Conversation

@mortimr
Copy link

@mortimr mortimr commented Jan 10, 2026

Summary

This PR fixes nested agent questions not appearing in the TUI and improves question tool UX.
Fixes #7654

Problem

When using ohmyopencode (or similar setups) with sub-agents spawning other agents via background_task, questions from deeply nested agents don't show up in the main session's TUI. The old code only looked at direct children sessions, missing questions from grandchildren and beyond.

To reproduce (without this PR):

Do the following:
- spawn one subagent
- from this subagent spawn 3 background_task and give them a name (one, two and three)
- in each background_task ask 3 questions (ask if I prefer python or typescript). Include both the background_task name and the question number.
Once all is done, give me a summary of all answers

The questions never appear in the TUI.

Solution

Core Fix: Nested Agent Questions

  • Changed from direct children lookup to BFS traversal of all session descendants
  • Questions from any depth now surface to the root session
  • Added from parameter so users know which agent is asking ("Question from explorer-agent")

QoL Improvements

The remaining changes are quality-of-life tweaks to improve the interview workflow:

  • Answer display: Table layout with borders, word wrapping, multi-select answers on separate lines
  • Multi-select UX: Checkbox prefixes (/), space to toggle, enter to confirm
  • Question type indicator: "Single"/"Multiple" tag in bottom bar
  • State reset: Fix stale selections bleeding into new questions

Test Infrastructure

  • OPENCODE_TEST_SKIP_GIT env var to skip git init (for commit signing setups)
  • Print OPENCODE_TEST_* vars at test start for visibility

Verification

  • Tested the reproduction prompt above - questions now appear
  • Manually verified single/multi-select flows
  • Added tests for from field

Screenshots

Short single without from

Screenshot 2026-01-10 at 23 26 22

Short single with from

Screenshot 2026-01-10 at 23 26 50

Simple Multi-select without from

Screenshot 2026-01-10 at 23 27 30

Simple Multi-select with from

Screenshot 2026-01-10 at 23 29 29

Multi-Question

Screenshot 2026-01-10 at 23 28 12

Long Markdown question (dark zone is scrollable)

Screenshot 2026-01-10 at 23 19 22

Support for Markdown in the discussion answers

Screenshot 2026-01-10 at 23 12 31

(this PR was mainly done by opencode with my supervision, I've been using the question workflow heavily lately with the https://github.com/paulp-o/ask-user-questions-mcp MCP. It's so great that we have questions natively in opencode now, but there descendant issue was preventing my old workflows from working properly as questions weren't bubbling up from lower than direct child agents. Also added some TUI improvements)

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my searches, I found no duplicate PRs. The searches returned PR #7653 (the current PR) and some tangentially related PRs (like PR #6681 for the ask_user tool feature and PR #5020 for the TUI layout system), but none that specifically address the nested agent questions issue or the specific UX improvements mentioned in this PR.

No duplicate PRs found

@mortimr mortimr changed the title feat(opencode): fix nested agent questions and improve question tool UX feat(questions): fix nested agent questions and improve question tool UX Jan 10, 2026
- Fix questions from nested sub-agents not surfacing to root session (BFS traversal)
- Add 'from' field to identify which agent is asking
- Improve answer display with bordered table layout
- Overhaul multi-select: checkbox prefixes, space to toggle, enter to confirm
- Add OPENCODE_TEST_SKIP_GIT env var for test fixtures
- Replace plain text rendering with syntax-highlighted code component for questions
- Add scrollable content area with height constraints for better readability
- Improve layout structure with proper flex properties and padding
- Update documentation to reflect markdown syntax support in question field
- Extract terminal dimensions for responsive layout calculations
@mortimr mortimr force-pushed the feat/questions/add-descendants-support-and-improve-experience branch from e8466a7 to 8cf1572 Compare January 10, 2026 21:33
@mortimr mortimr changed the title feat(questions): fix nested agent questions and improve question tool UX feat(questions): enhance questions TUI + add full descendants support Jan 11, 2026
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.

[BUG] Questions from nested sub-agents don't appear in TUI

1 participant