Skip to content

Commit 7a5fbdc

Browse files
Bulat Yapparovclaude
andcommitted
fix: propagate subagent permission events; clarify session_error scope
- run.ts: emit permission_rejected/permission_granted for subagent sessions too (previously filtered out), matching the existing subagent tool_use pass-through. Fixes an asymmetry where a subagent's denied tool surfaced as a failed tool_use with no explaining permission_rejected event. - EVENTS.md: document that session_error is strictly for abnormal termination; session_complete.error may carry concatenated non-fatal errors without a preceding session_error. Alerting should key on session_error. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent a95d7dc commit 7a5fbdc

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎EVENTS.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Emitted once when the session ends (success or failure).
4949
`error` is `null` on success, or a string describing the failure.
5050

5151
> **Deprecated in v1.** Prefer the structured `session_error` event for new consumers. `session_complete.error` remains populated for back-compat and will be removed in a future schema version.
52+
>
53+
> Note: `session_error` is only emitted when the session terminates abnormally (provider/auth/rate-limit/timeout/OOM). Non-fatal errors that accumulate during an otherwise-successful run surface as individual `error` events and may also appear concatenated in `session_complete.error` without a preceding `session_error`. Alerting logic should key on `session_error`, not on `session_complete.error`.
5254
5355
### `session_error`
5456

‎packages/cli/src/cli/cmd/run.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@ export const RunCommand = cmd({
625625

626626
if (event.type === "permission.asked") {
627627
const permission = event.properties
628-
if (permission.sessionID !== sessionID) continue
628+
const ownSession = permission.sessionID === sessionID
629+
if (!ownSession && !childSessions.has(permission.sessionID)) continue
629630
emit("permission_rejected", {
630631
callID: permission.tool?.callID,
631632
tool: (permission.metadata?.tool as string | undefined) ?? permission.permission,
@@ -648,7 +649,7 @@ export const RunCommand = cmd({
648649

649650
if (event.type === "permission.granted") {
650651
const permission = event.properties
651-
if (permission.sessionID !== sessionID) continue
652+
if (permission.sessionID !== sessionID && !childSessions.has(permission.sessionID)) continue
652653
emit("permission_granted", {
653654
callID: permission.tool?.callID,
654655
tool: (permission.metadata?.tool as string | undefined) ?? permission.permission,

0 commit comments

Comments
 (0)