Skip to content

fix(agent-status): keep a nested child's model off the parent row - #25687

Closed
Regis-RCR wants to merge 1 commit into
stablyai:mainfrom
Regis-RCR:contrib/nested-model-fence
Closed

Regis-RCR wants to merge 1 commit into
stablyai:mainfrom
Regis-RCR:contrib/nested-model-fence

Conversation

@Regis-RCR

Copy link
Copy Markdown
Contributor

ELI5

A Claude Code session can run another agent inside its own terminal, for example codex exec for a review. That inner agent reports its own model to Orca on the same pane. Orca already knew to keep calling that pane "Claude", but it took the inner agent's model name anyway. The sidebar and the agent dashboard then labelled the Claude session with the Codex model, and the label stayed there after the inner agent finished. This change keeps the parent's model when the event comes from a nested child.

What Changed

Before: a Claude Code pane running Opus showed gpt-6-astra (the model in ~/.codex/config.toml) in its sidebar card and dashboard row after it ran codex exec. It kept showing it until a new model arrived. For Claude that never happens: Orca's Claude hook normalizer emits no model, so later Claude statuses never replace it.

After: the Claude row keeps its own model (or none, if it never reported one) while the nested child runs and after it exits. Unchanged: a pane whose own agent changes model, a Codex pane's own model, and a pane whose agent legitimately changes after the previous one is done or stale.

Mechanism: in src/main/agent-hooks/server/server-status-update.ts, resolveAgentStatusIdentity can report inheritedFromActivePane, meaning the event comes from a child on the active parent's pane key. In that case the payload already had its agentType rewritten to the parent's. It now also drops the child's model and carries the parent row's previous model instead. Nothing else in the payload changes. The fence runs at the same point as the existing identity fence, before the cancel latch and the permission hold.

Why

The identity fence was added so a nested CLI cannot take over its parent's row, but the model rode through it. The label is what an operator reads to know which model a session runs, so a wrong one is worse than none.

Alternatives considered:

  • A second fence in the renderer slice, as in fix(agent-status): keep a nested child hook's model off the fenced parent row #13602. I tried it and removed it. On both the base and the patched host, a child event fenced by the host reaches the renderer already carrying the parent's agentType, and the fields that would identify a child event (source, hookEventName) are not forwarded to the renderer. So a renderer fence keyed on a type mismatch does not fix this path, and the test that exercised it injected a payload the host does not send.
  • Skipping Orca's Codex hook when it runs under another agent (the approach in fix(codex): skip the Codex hook under a Claude background job #24641 for background jobs). That would also hide the child's own status, which is useful. This change keeps the events and only stops the model from relabelling the parent.

This supersedes #13602 by @brennanb2025, which fixed the same leak against the pre-split src/main/agent-hooks/server.ts. The main-side idea is the same, adapted to the current file layout. Two parts of #13602 are intentionally left out: preserving the model on Claude completion events (a separate, pre-existing behaviour) and the renderer fence (see above).

Mixed-version limit: the fix lives in the host. A newer desktop or web client paired with an older runtime host still shows the nested agent's model on the parent row until that host is updated. The older host has already relabelled the event as the parent agent, and it sends nothing the client could use to tell it apart. A desktop app's renderer ships with its own host, so a single install is not affected. Mobile and orca worktree ps read host rows directly and pick up the fix when the host updates.

Out of scope, pre-existing: a nested child's modelSwitchCommand still passes through. Only the pi-family agents send one, and its consumer applies it to that agent only. Also, the fence applies only where the existing identity fence does: the incoming agent type differs from the parent's, and the parent row is confirmed, not done, and was refreshed within the last 30 minutes. Same-agent nesting (Claude inside Claude) and child events arriving after that window are not covered.

Linked Issue

Fixes #25686

Visual Proof

Before, on 1.4.220: a Claude Code session on Opus whose card reads gpt-6-astra, with Claude Code's own statusline in the same terminal reading Opus. Unrelated text is blurred.

Claude Code session on Opus labelled gpt-6-astra

After: covered by a host test that posts real Claude and Codex hook bodies through the server and asserts that no status pushed to the renderer carries the nested model. No visual change beyond the label.

Testing

  • src/main/agent-hooks/server-nested-agent-model.test.ts (new, 7 tests): the parent keeps its model when a nested hook reports one; a parent that never reported a model shows none; a Codex parent keeps its model through a nested model-less hook; a genuine model switch by the pane's own agent still applies; a Codex pane's own model still shows; an agent change after done still takes over; and one test that posts real hook bodies and inspects every event pushed to the renderer. 4 of the 7 fail on main and pass with this change.

  • pnpm tc, oxlint and oxfmt on the touched files, pnpm run check:code-quality:changed, and the agent-hooks and agent-status test files (1925 passing) all pass.

  • macOS only. Run under Node 26 (the repo pins 24, which I don't have on this machine). I did not run the full pnpm test, pnpm build or e2e.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Assisted by Claude (Anthropic).

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

When an agent pane runs a nested agent CLI such as codex exec, the
child's hooks fire on the inherited pane key. The identity fence already
relabels those events as the parent agent, but the child's model passed
through and stayed on the parent row after the child exited. Keep the
parent's previous model (or none) for events the fence marks as inherited
from the active pane.
Copilot AI balanced review requested due to automatic review settings October 5, 2026 21:19
@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5fa765ed-f125-4f2d-80cd-a31e2d18ae88
📥 Commits

Reviewing files that changed from the base of the PR and between a3bd6a6 and 10aff0d.

📒 Files selected for processing (2)
  • src/main/agent-hooks/server-nested-agent-model.test.ts
  • src/main/agent-hooks/server/server-status-update.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

When an agent inherits identity from an active pane, the status update path now omits the incoming model and retains the previous row’s model when available. Added tests cover nested and standalone agent model behavior, including events pushed to the renderer.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 10aff

The change is mergeable after normal checks; no actionable risk to the parent model label remains identified.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to 10aff

The change preserves the parent session’s display metadata without expanding access, permissions, or network exposure. No material security risk was found in the changed behavior.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed outcome is model metadata on stored and pushed pane-status rows selected by the existing active-parent identity rule. The delta does not add callers, widen transport exposure, or grant additional execution authority.

Trust Boundaries and Controls

  • observed — The existing HTTP ingress requires the per-server hook token before reading the body and binds to loopback. The new HTTP test supplies that token through the unchanged request helper; it does not bypass or modify these controls.

Resilience and Maintainability Implications

  • inferred — The model fence adds no asynchronous transition or new mutable store. Repeated inherited updates preserve the current parent model, nested terminal updates remain suppressed, and existing admission and cancellation paths retain their ordering. Static tracing supports preservation of these invariants without claiming exhaustive recovery or concurrency validation.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: preventing a nested agent’s model from appearing on the parent row.
Description check ✅ Passed The description covers the change, reason, linked issue, implementation, scope, and testing. The visual proof section includes a before image but no after image or the template’s required N/A statemen…
Linked Issues check ✅ Passed Issue #25686 requires a nested child’s model to not replace the parent row’s model. In server-status-update.ts, events marked inheritedFromActivePane use the parent agent type and retain the previ…
Out of Scope Changes check ✅ Passed The changes are limited to host-side model handling for inherited nested-agent status events and tests for that behavior. The tests also check that normal agent model changes and standalone Codex mode…
  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The focused fix matches the existing identity fence and has comprehensive regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents nested agents from overwriting the parent pane’s displayed model.

Changes:

  • Preserves the active parent’s model during identity fencing.
  • Adds seven regression tests covering nested and legitimate model changes.
File Description
server-status-update.ts Fences nested child models.
server-nested-agent-model.test.ts Tests model-fencing behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Host-side model fence for nested children — In applyNormalizedStatus, when the existing identity fence reports inheritedFromActivePane, the child's model is now stripped and the parent row's prior model is carried forward instead, so a nested codex exec can no longer relabel its Claude parent.
  • Regression tests — server-nested-agent-model.test.ts adds 7 cases covering model preservation/drop, genuine same-agent model switches, a Codex parent surviving a model-less child, an agent taking over after done, and an end-to-end HTTP test asserting no pushed renderer event carries the nested model.

I confirmed the tests actually pin the behavior: all 7 pass with the patch, and 4 of them fail when the source hunk is reverted to base. The fence sits at the same choke point as the existing identity fence, which every ingress path (local hooks, ingestRemote, inference, retries) converges on, so no separate lane needs the same guard.

The PR body already documents the intentional boundaries (same-agent nesting, the 30-minute freshness window, modelSwitchCommand, and the host-side mixed-version limit), so there is nothing left to flag.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

OrcaWin pushed a commit that referenced this pull request Oct 11, 2026
Preserve the parent's model when the existing identity fence retains an
active parent for a nested CLI hook. Exercise native SessionStart and Stop
bodies alongside model updates and legitimate pane takeovers.

Adapted from PR #25687, with real native-hook and hidden renderer proof.

Co-authored-by: Regis <[email protected]>
OrcaWin pushed a commit that referenced this pull request Oct 11, 2026
* fix(agent-status): keep nested models off the parent pane

Preserve the parent's model when the existing identity fence retains an
active parent for a nested CLI hook. Exercise native SessionStart and Stop
bodies alongside model updates and legitimate pane takeovers.

Adapted from PR #25687, with real native-hook and hidden renderer proof.

Co-authored-by: Regis <[email protected]>

* chore: record original authorship for Parent-pane model ownership

Records the retained adapted contribution from #13602 in replacement PR #26846.

Co-authored-by: Brennan Benson <[email protected]>

* test: drop redundant single-agent model case

---------

Co-authored-by: Regis <[email protected]>
Co-authored-by: Brennan Benson <[email protected]>
Co-authored-by: m4air <[email protected]>
@nwparker

Copy link
Copy Markdown
Contributor

Closing as superseded. #25686 was already closed by #26846; merged #29264 now rejects the entire inherited cross-provider update before it can overwrite the parent's model, prompt, session, children, or freshness. Its regression coverage includes server-nested-agent-model.test.ts, including the real hook-HTTP publication case from this investigation. Merged #29386 extends ownership through an identified idle foreground process.

The model tests passed in the final 197-test focused suite. This narrower model-only patch is no longer needed.

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.

Claude Code session shows the Codex model after running codex exec in its pane

3 participants