Skip to content

[Bug]: Claude Code background agents (started by Claude Code, not Orca) inherit the parent pane's ORCA_PANE_KEY, so they never get their own sidebar row #34188

Open

Description

@AndresCreator

Operating system

macOS (Darwin 25.6, arm64)

Orca version

1.4.237 · Claude Code 2.1.311

Details

Short summary. Claude Code can start background agents itself (its own job/daemon backend: the left-arrow "new agent" in Claude Code's agent view, /bg, etc.). When that happens from a Claude session running in an Orca pane, the new agent inherits the parent pane's ORCA_PANE_KEY, ORCA_TAB_ID, ORCA_WORKTREE_ID, ORCA_WORKSPACE_ID, ORCA_AGENT_HOOK_* and launch token. Orca's hook therefore reports the new agent's events under the parent pane's key, so the new agent never gets its own row in the sidebar. Its status merges into, or is overwritten by, the parent pane's row.

This looks like the same root cause as #26417, but on a path that the fix in #27204 can't reach: the child is started by Claude Code's background-job process, not by Orca, so Orca never builds its environment.

Steps to reproduce

  1. Open a Claude Code agent in an Orca pane (workspace A).
  2. In Claude Code, create a new background agent (left arrow → new agent in the agent view).
  3. Watch Orca's left sidebar.

Expected: a new agent row for the new session (or a child row under the parent).
Actual: no new row. Inside the new agent, env | grep ORCA_ shows 24 ORCA_* variables, and ORCA_PANE_KEY equals the parent pane's key. agent-hooks/last-status.json has no entry for the new session's session_id; the only entry for that pane key still carries the parent's providerSession.id. logs/daemon.log has no session-created for it, because Orca didn't start it.

Suggested fix (either side)

  • In claude-hook.sh / the hook receiver: when a payload's session_id differs from the session already bound to that paneKey and the child is a Claude Code background job (CLAUDE_JOB_DIR / CLAUDE_CODE_CHILD_SESSION are set in its env), register it as a separate (child) agent row instead of folding it into the pane.
  • Or, when it's ambiguous, drop events whose session_id doesn't match the pane's bound session rather than overwriting the pane's state.

Related: #26417, #27204, #25189, #33105.

Activity

  1. eatmoreduck commented on Oct 27, 2026

    @eatmoreduck
    Contributor

    Dug into the listener side to see what Orca can actually observe on this path, and there are two existing pieces that matter for scoping a fix:

    1. Claude-job hook events are already declined on purpose. ClaudeSessionContinuationTracker (src/shared/agent-hook-listener/claude-session-continuation.ts) documents that when Claude Code forks a pane's session into a daemon job, "that job's hooks are declined (fix(agent-hooks): stop backgrounded Claude sessions posting a stale pane key (STA-4769) #15304), so the pane's own transcript is the only evidence of where the conversation went." So for the /clear-style fork path, Orca deliberately does not trust hook events from the job and instead follows the continued-in record in the parent transcript to keep the pane row pointing at the live session (including the jobs/<id>/state.json variant when /clear happens inside the job).

    2. The open question for this issue's exact path is which of two failure modes you're seeing:

      • If the new background agent's hook events are declined too (same fix(agent-hooks): stop backgrounded Claude sessions posting a stale pane key (STA-4769) #15304 decision), then no event ever names a pane — the row is missing because nothing is observed at all, and the fix would be discovery-side: teach the continuation tracker (or a sibling of it) to spawn a child row for the fork rather than re-pointing the pane row, which today it can't express since resolvePaneClaudeContinuation only has one paneKey to work with.
      • If the new agent's hooks do fire and are accepted under the inherited ORCA_PANE_KEY, that contradicts the decline decision and the fix is at the envelope/decline layer.

    Two things that would pin this down from your setup:

    • Does the parent pane's transcript (~/.claude/projects/<cwd slug>/<parent session>.jsonl) contain a continued-in record naming the background agent's session id for the /bg / agent-view new-agent path, the way it does for the fork path the tracker follows today?
    • In Orca's main log around creating the background agent, are there declined hook deliveries for the new session id (the fix(agent-hooks): stop backgrounded Claude sessions posting a stale pane key (STA-4769) #15304 decline path logs), or accepted hook deliveries carrying the parent pane key?

    Not attempting a PR yet — which lever is correct depends on those answers, and re-shaping the pane-key→row model for child rows looks like a design change that belongs with the maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions