opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Session does not automatically return to parent after subagent execution

Open mossbergmaverick opened this issue 3 weeks ago • 2 comments

Description

When working with a subagent, the system correctly handles the transition to a child session (e.g., when permissions are required). However, once the child session's task is completed or permissions are granted, the focus remains in the child session.

Currently, the user has to switch back to the parent session manually every time, which creates significant friction and undermines the efficiency of using subagents.

Expected Behavior: The session should automatically return to the parent context once the subagent's specific task or permission check is finished.

Actual Behavior: The user stays stuck in the child session and must perform a manual switch to continue working in the parent session.

Additional Context: This manual overhead defeats the purpose of a seamless subagent workflow. Ideally, the child session should be ephemeral or automatically yield back to the parent.

OpenCode version

1.0.218

Steps to reproduce

  1. Start a task in the parent session.
  2. Trigger an action that invokes a subagent (requiring a switch to a child session).
  3. Complete the required action/permission in the child session.
  4. Observe that the session remains in the "child" state instead of reverting.

Screenshot and/or share link

No response

Operating System

macOS Sonoma 15.7.3

Terminal

VSCode

mossbergmaverick avatar Dec 31 '25 00:12 mossbergmaverick

This issue might be a duplicate of existing issues. Please check:

  • #3291: [FEATURE]: Navigation to parent session from child/subagent sessions - Proposes keybindings to navigate between parent/child sessions
  • #4432: [FEATURE]: "session_child_return_to_parent" in keybinds - Requests a keybind to return to parent session
  • #5001: [FEATURE]: make subagent visually more distinctive - Notes that automatic switching to subagents for permissions is confusing
  • #4422: Primary agent responds in subagent view; delegated subagent views become inaccessible - Related issue with subagent session navigation problems

Feel free to ignore if none of these address your specific case.

github-actions[bot] avatar Dec 31 '25 00:12 github-actions[bot]

Yeah thats a good point, subagent ux is being thought about more rn

rekram1-node avatar Dec 31 '25 00:12 rekram1-node

I suspect this behavior might be a regression, but in any case, it creates a few critical issues:

  1. Security Risks: When focus shifts to the subagent's session, the permission scope changes, potentially allowing that session to spawn nested sub-sessions.
  2. Navigation Lock: There is no way to return to the parent session while a permission prompt is active.
  3. Race Condition: If the user presses Esc to stop the subagent, the primary agent might try to resume or recreate the subagent faster than the user can switch back to the parent context.

diogosalazar avatar Dec 31 '25 20:12 diogosalazar