Skip to content

ENG-5106 Create new agents at the current view's depth with ctrl+n - #1136

Open
snimu wants to merge 6 commits into
mainfrom
eng-5106
Open

ENG-5106 Create new agents at the current view's depth with ctrl+n#1136
snimu wants to merge 6 commits into
mainfrom
eng-5106

Conversation

@snimu

@snimu snimu commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Fixes ENG-5106.

What this does

When you are looking at the subagents of a particular agent and press ctrl+n, the new agent is now created under that agent, at that level — instead of always being created as a new top-level agent.

Why

Pressing ctrl+n inside a drilled-in view clearly signals "give me a new agent here". Creating it at the top level instead was surprising and meant extra steps to get the agent where you wanted it.

How it works

  • When the view is scoped to a parent agent, ctrl+n now passes that parent along when asking the daemon to create the session, using a metadata field that already existed on the create request — the wire format did not change shape.
  • The daemon then records the parent and the level in the new session's header, so the new agent shows up in the right place in the tree.
  • Old daemons don't know how to do this, so the feature only turns on when the daemon says it supports it (a new advertised capability). With an older daemon, ctrl+n simply behaves as before. This follows the repository's rules for protocol changes.
  • Abandoned drafts created this way are cleaned up the same way top-level drafts are.

Changes

  • agents-view-mode.ts: send the parent info when the view is scoped (+15 lines).
  • daemon-mode.ts: create the session under the given parent (+20/−1 lines).
  • daemon-protocol.ts: advertise the new capability (+5/−1 lines).
  • Tests: new coverage in the agents-view and daemon test files (+179 lines).
  • One changelog entry.

Lines changed: source +40/−2, tests +179/−0, changelog +1/−0.

Checks

  • npm run check clean.
  • 254 tests across the four touched test files, all passing.
  • Review went through two rounds; the first round led to the capability gating and the draft cleanup fix.

Note

Medium Risk
Touches daemon session creation and parent/child tree linkage, which can misplace agents if wrong. Mitigated by capability gating and solid test coverage.

Overview
Ctrl+N in a scoped agents view now creates the new agent under that scope root, instead of always at the top level.

When the view is drilled into a parent, create sends runtimeMetadata with parent linkage. The daemon writes parentSession and rlmDepth into the new session header so it appears at the correct tree depth. Gated on the new scoped_session_create capability; older daemons keep the previous top-level behavior.

Also treats user-created scoped drafts (no rlmChildId) as discardable like top-level drafts, while kernel children stay non-discardable. Worker restore IDs now apply to scoped creates as well as top-level ones.

Reviewed by Cursor Bugbot for commit 232768c. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Create new agents at the current scope depth with Ctrl+N in agents view

  • When Ctrl+N is pressed in a scoped agents view and the daemon advertises the scoped_session_create capability, the new session is created as a subagent anchored to the scope root's parent session file and depth, rather than at the top level.
  • AgentsViewMode.createNewSession calls client.waitForHello() and checks for the capability before including runtimeMetadata in the create request; falls back to top-level creation if the daemon lacks the capability or the scope root has no session file.
  • The daemon's createRuntime handler uses runtimeMetadata.parentSessionFile to set parentSession and rlmDepth headers on the new session.
  • User-created scoped agent drafts (no rlmChildId) are now treated as discardable when empty and idle; kernel-spawned child drafts remain protected.
  • Behavioral Change: AgentDaemon.addRuntime now consumes the stored restoreActiveSessionId regardless of runtime metadata kind, clearing it after use.

Macroscope summarized 232768c.

Comment thread packages/coding-agent/src/modes/agents-view/agents-view-mode.ts Outdated

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ab75d0b. Configure here.

Comment thread packages/coding-agent/src/modes/agents-view/agents-view-mode.ts
snimu added 2 commits August 10, 2026 15:08
- require a persisted scope-root sessionFile before sending scoped-create metadata
- drop parentActiveSessionId from scoped-create metadata so parent closure does not cascade to ctrl+n-created agents
- keep kernel-managed subagent mocks classified via rlmChildId in the ENG-4601 regression tests
- await the daemon hello before evaluating the scoped_session_create
  capability so scoped metadata is not silently dropped
- honor the worker-assigned root active session id for subagent-kind
  root creates so supervisor-mode scoped creation no longer fails
@snimu snimu changed the title Create new agents at the current view's depth with ctrl+n ENG-5106 Create new agents at the current view's depth with ctrl+n Aug 10, 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.

1 participant