Skip to content

fix(claude): drop the parent Claude Code session's markers from every claude OAR starts - #310

Merged
xxchan merged 2 commits into
mainfrom
fix/claude-parent-session-markers
Oct 10, 2026
Merged

xxchan merged 2 commits into
mainfrom
fix/claude-parent-session-markers

Conversation

@xxchan

@xxchan xxchan commented Oct 10, 2026

Copy link
Copy Markdown
Member

Closes #309.

A host started from inside Claude Code (its Bash tool, a hook) inherits that session's markers. OAR removed only CLAUDECODE and, since #307, CLAUDE_CODE_ENTRYPOINT. Lookout's static read of claude 2.1.292 plus a mock-provider run found what the rest do:

  • CLAUDE_CODE_CHILD_SESSION: claude counts it, like CLAUDECODE, as "running inside a Claude Code session". In print mode that turns off skill proposals, refuses org memory, and skips prompt history.
  • CLAUDE_CODE_MESSAGING_TOKEN: the parent session's credential, which OAR passed into the child.
  • The others: no effect in -p, or claude overwrites them. Claude itself drops them when it launches an independent claude (its daemon launcher).

Change: runtimes/claude/environment.ts holds the list. It is claude's own launcher list (CLAUDECODE, CLAUDE_CODE_SESSION_ID, CLAUDE_CODE_CHILD_SESSION, CLAUDE_CODE_SESSION_ATTENDED, CLAUDE_CODE_CHROME_MCP_ORG_DENIED, CLAUDE_CODE_EVAL_INTERVIEW_SESSION, CLAUDE_CODE_BRIDGE_SESSION_ID, CLAUDE_CODE_HOST_WORKTREE, CLAUDE_CODE_HOST_WORKTREE_FENCE, CLAUDE_CODE_ENTRYPOINT) plus CLAUDE_CODE_MESSAGING_SOCKET and CLAUDE_CODE_MESSAGING_TOKEN.

  • Sessions drop all of them; an explicit SessionOptions.env value still wins, except CLAUDECODE.
  • The claude subcommands OAR runs (auth status, login, logout, account usage, model list, inventory) use the same list.
  • TRACEPARENT (trace context) and an AI_AGENT set by another tool pass through.

Tests: tests/claude/claude-launch-env.test.ts. Every marker is removed from a session and from the subcommand environment, the two configuration variables pass, an explicit value wins, CLAUDECODE can't be set, and the host's own environment is untouched. Full suite (1,535), lint and typecheck pass locally. Docs: docs/runtimes/claude.md.

🤖 Generated with Claude Code

exe.dev user and others added 2 commits October 10, 2026 06:13
… claude OAR starts

A host started from inside Claude Code (its Bash tool, a hook) inherits that
session's markers. OAR removed only CLAUDECODE and, since #307, the
entrypoint, so a claude it started still saw CLAUDE_CODE_CHILD_SESSION and
treated itself as part of the parent session (skill proposals off, org
memory refused, no prompt history), and received the parent's messaging
token. Sessions and the claude subcommands (auth, usage, model list,
inventory) now drop the list claude itself drops when it launches an
independent claude (2.1.292), plus the messaging socket and token.
TRACEPARENT and another tool's AI_AGENT pass; an explicit SessionOptions.env
value still wins, except CLAUDECODE.

Closes #309.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lookout found claude update (and the --version probe) still inherited all
twelve markers, including the parent's messaging token. The updater now
starts from claudeEnv() before the shared script-context filter. The probe
and the vendor install script stay on the shared paths; the docs say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan merged commit 81906aa into main Oct 10, 2026
17 checks passed
@xxchan
xxchan deleted the fix/claude-parent-session-markers branch October 10, 2026 06:29
@xxchan xxchan mentioned this pull request Oct 10, 2026
xxchan added a commit that referenced this pull request Oct 10, 2026
Release OAR and CLI 0.53.0. This PR changes only the two package version
fields.

**Fixed: a host prompt gets its own answer on claude** (#308, #313)
- A host prompt sent while claude is busy (for example as a background
task finishes) can wait behind a turn claude starts on its own. OAR used
to end the prompt at that other turn's result and hand the host the
wrong text. claude now reports each prompt's own `command_lifecycle`
(`queued`, then `started`), and OAR attributes the turn by it:
- `input_queued { inputId }` (new) means claude holds the input and has
not started its turn;
- `turn_active` gains an optional `inputId` for the input whose turn
claude started;
  - a turn without that id while the prompt waits is a separate turn.
`promptAndWait`, `awaitTurnEnd(…, inputId)`, `awaitIdle`, `statusOf` and
the session view all follow this, live and on replay. An ordinary prompt
shows no change: no idle flicker and no moved bubble.
- `promptAndWait` now sends a fresh UUID `inputId` when the caller gives
none. `awaitTurnEnd` takes an optional `inputId`.
- **`abort()` while a host prompt is still queued** sends claude's
interrupt with `cancel_queued` (when claude declares
`interrupt_cancel_queued_v1`). The queued prompt is cancelled with the
running turn, and `input_dropped { reason: "turn_interrupted" }` hands
it back. Cost: claude also drops queued task notifications that have no
id.
- **A reused `inputId`:** claude ignores a user message whose id it has
already seen. OAR used to wait until the abort fallback killed the
process. Now `input_dropped { reason: "runtime_refused", failure:
"invalid_request", message }` is emitted at once and the session takes
the next prompt. Resend a dropped input with a **new** `inputId` on
claude.

**Added: claude workflow runs are tasks** (#305, #307)
- Claude Code's local workflows (`local_workflow`) are reported as
`TaskType` `"workflow"`, and agent teammates (`in_process_teammate`) as
`"agent"`. A changed `task_progress.description` becomes `task_updated`.
The phase and agent list (`workflow_progress`) stays in the native frame
only, because it is outside claude's SDK schema. A workflow's spend
appears in a later `result.modelUsage`.
- A turn claude starts on its own (after a workflow, a queued message, a
late steer) now emits `turn_active` at once, so the host does not show
idle until text arrives.

**Fixed: claude sessions no longer inherit a parent Claude Code
session's markers** (#303, #307, #309, #310)
- A host started from inside Claude Code passed that session's markers
to every claude OAR started. The worst cases:
`CLAUDE_CODE_CHILD_SESSION`, which made claude treat itself as part of
the parent session; an inherited `CLAUDE_CODE_ENTRYPOINT`, which made an
API-key session fail with "Not logged in"; and the parent's
`CLAUDE_CODE_MESSAGING_TOKEN`. Sessions and the claude subcommands OAR
runs (auth, login, logout, usage, model list, inventory, `claude
update`) now drop the twelve markers claude itself drops when it
launches an independent claude. An explicit `SessionOptions.env` value
still wins, except `CLAUDECODE`.
- A `compaction_ended` received while idle leaves status idle.

**Added: install steps when OAR won't run them** (#311)
- `requires_privileges` and `missing_tool` answers now carry the
vendor's `steps` and `source`, for a person to run once they have the
rights or the tool. OAR runs none of them.

**Behavior changes**
- New event kinds `input_queued`, plus optional fields on `turn_active`
(`inputId`) and `input_dropped` (`failure`, `message`, only with
`runtime_refused`). Hosts with an exhaustive `switch` need the new case.
- `TaskType` gains `"workflow"`.
- `promptAndWait` always sends an `inputId`, so the input's identity in
`ConversationInput` is that id, not the request id.
- On claude, resend a dropped input with a new `inputId`.

Validation: every PR passed all 17 checks on its final head. #307
differed from its CI tree only in the version fields from the 0.52.0
release. #311 was verified locally on top of #310 (typecheck, lint, full
tests), and its merged tree equals that verified tree. #310 and #313
merged with trees equal to their CI trees. Lookout verified each against
the real claude CLI with a mock provider, with no account: three
workflow recordings, the environment of every claude process, and more
than a dozen lifecycle recordings for #313 (collision, steer, queue,
cancel before and after start, plain interrupt, fold-in, duplicate after
drop and after resume). After this PR passes CI and merges, tag its
exact squash commit as `v0.53.0` to trigger npm trusted publishing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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: check which inherited CLAUDE_CODE_* parent-session variables must not reach a child session

1 participant