Repository navigation
fix(server): Claude turns blocked by Auto-mode denials need attention #34969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0fc9ff1
dbbcccf
208e762
dc72317
f54f0bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4430,6 +4430,34 @@ function claudeRewrittenVersion( | |
| : undefined; | ||
| } | ||
|
|
||
| // Auto mode's classifier and deny rules refuse tool calls inside the CLI, so | ||
| // T3 never sees a request; the result's permission_denials is the only record. | ||
| function cliPermissionDenialFailure( | ||
| message: SDKResultMessage, | ||
| hostDecidedToolUseIds: ReadonlySet<string>, | ||
| ): OrchestrationV2ProviderFailure | null { | ||
| const denied = message.permission_denials.filter( | ||
| (denial) => !hostDecidedToolUseIds.has(denial.tool_use_id), | ||
| ); | ||
| if (denied.length === 0) { | ||
| return null; | ||
| } | ||
| return makeProviderFailure({ | ||
| class: "permission_error", | ||
| code: "permission_denied", | ||
| retryable: false, | ||
| message: [ | ||
| "Claude's permission settings blocked:", | ||
| ...denied.map((denial) => | ||
| summarizeClaudeToolRequest( | ||
| denial.tool_name, | ||
| claudeNativeToolInputFromRecord(denial.tool_input), | ||
| ), | ||
| ), | ||
| ].join("\n"), | ||
| }); | ||
| } | ||
|
|
||
| function providerFailureFromResult( | ||
| message: SDKResultMessage, | ||
| receivedAt: DateTime.Utc, | ||
|
|
@@ -4765,6 +4793,8 @@ interface ActiveClaudeTurnContext { | |
| >; | ||
| // Claude may settle a turn with a result that echoes only a steer's uuid. | ||
| readonly steerUuids: Set<string>; | ||
| // Tool calls T3's canUseTool decided; the result's permission_denials also lists those. | ||
| readonly hostDecidedToolUseIds: Set<string>; | ||
| // Claude can run another model than requested, such as when an organization disallows it. | ||
| executedModel: string | undefined; | ||
| } | ||
|
|
@@ -8634,9 +8664,12 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( | |
| >; | ||
| readonly completedAt: DateTime.Utc; | ||
| readonly failure?: OrchestrationV2ProviderFailure; | ||
| // Reports the turn as failed without the cleanup a stopped turn gets: the process and its background work live on. | ||
| readonly reportedFailure?: OrchestrationV2ProviderFailure; | ||
| readonly threadDisposition?: "reusable" | "broken"; | ||
| readonly result?: SDKResultMessage; | ||
| }) { | ||
| const reportedStatus = input.reportedFailure === undefined ? input.status : "failed"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the reported outcome when completing a goal. If an active Preserve the underlying status for resource cleanup, but require
|
||
| input.context.steersClosed = true; | ||
| yield* reasoningDeltas.flushTurn(input.context.nativeTurnId); | ||
| if (input.status === "completed") { | ||
|
|
@@ -8836,7 +8869,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( | |
|
|
||
| const threadDisposition = input.threadDisposition ?? "reusable"; | ||
| const terminalEvent: ProviderAdapter.ProviderAdapterV2Event = | ||
| input.status === "failed" | ||
| reportedStatus === "failed" | ||
| ? { | ||
| type: "turn.terminal", | ||
| driver: CLAUDE_PROVIDER, | ||
|
|
@@ -8847,14 +8880,18 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( | |
| input.context, | ||
| `terminal-failure:${input.context.providerTurnId}`, | ||
| ), | ||
| status: input.status, | ||
| failure: input.failure ?? makeProviderFailure({ class: "provider_error" }), | ||
| status: reportedStatus, | ||
|
macroscopeapp[bot] marked this conversation as resolved.
Resolved
|
||
| failure: | ||
| input.reportedFailure ?? | ||
| input.failure ?? | ||
| makeProviderFailure({ class: "provider_error" }), | ||
| ...(providerRetry === undefined | ||
| ? {} | ||
| : { | ||
| retry: providerRetry.retry, | ||
| retryStartedAt: providerRetry.startedAt, | ||
| }), | ||
| ...(input.reportedFailure === undefined ? {} : { childTurnsContinue: true }), | ||
| threadDisposition, | ||
| } | ||
| : { | ||
|
|
@@ -8863,7 +8900,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( | |
| providerThreadId: input.context.input.providerThread.id, | ||
| providerTurnId: input.context.providerTurnId, | ||
| runOrdinal: input.context.input.runOrdinal, | ||
| status: input.status, | ||
| status: reportedStatus, | ||
| failure: null, | ||
| threadDisposition, | ||
| }; | ||
|
|
@@ -8875,7 +8912,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( | |
| providerTurn: { | ||
| ...providerTurnPayload({ | ||
| context: input.context, | ||
| status: input.status, | ||
| status: reportedStatus, | ||
| completedAt: input.completedAt, | ||
| }), | ||
| turnTokenUsage: normalizeClaudeTurnTokenUsage( | ||
|
|
@@ -11226,20 +11263,28 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( | |
| failureHint, | ||
| usageLimited, | ||
| ); | ||
| const resultStatus = interrupted | ||
| ? "interrupted" | ||
| : limitedCompaction !== null | ||
| ? "failed" | ||
| : terminalStatusFromResult(message, failureHint); | ||
| const permissionDenialFailure = | ||
| resultStatus === "completed" | ||
| ? cliPermissionDenialFailure(message, context.hostDecidedToolUseIds) | ||
| : null; | ||
| const terminalFailure = | ||
| resultFailure?.class === "usage_limit" | ||
| ? { ...resultFailure, resetAt: resetAt ?? resultFailure.resetAt ?? null } | ||
| : resultFailure; | ||
| yield* finalizeActiveTurn({ | ||
| context, | ||
| status: interrupted | ||
| ? "interrupted" | ||
| : limitedCompaction !== null | ||
| ? "failed" | ||
| : terminalStatusFromResult(message, failureHint), | ||
| status: resultStatus, | ||
| completedAt, | ||
| result: message, | ||
| ...(terminalFailure === null ? {} : { failure: terminalFailure }), | ||
| ...(permissionDenialFailure === null | ||
| ? {} | ||
| : { reportedFailure: permissionDenialFailure }), | ||
| }); | ||
| } | ||
| }); | ||
|
|
@@ -11475,6 +11520,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( | |
| } | ||
|
|
||
| const nativeRequestId = callbackOptions.toolUseID; | ||
| context.hostDecidedToolUseIds.add(nativeRequestId); | ||
| const nativeToolInput = claudeNativeToolInputFromRecord(toolInput); | ||
| const heldForEcho = context.heldRootFrames.length > 0; | ||
| const startToolCall = toolName !== "Agent" && options?.startToolCall !== false; | ||
|
|
@@ -12479,6 +12525,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( | |
| heldRootFrames: [], | ||
| pendingSteers: new Map(), | ||
| steerUuids: new Set(), | ||
| hostDecidedToolUseIds: new Set(), | ||
| executedModel: undefined, | ||
| }; | ||
| const attachTurn = Effect.gen(function* () { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Limit the permission-denial failure message to what the user needs to act on.
cliPermissionDenialFailureplaces raw tool input in the message.summarizeClaudeToolRequestcopies a Bashcommandor file path up to 400 characters, so a credential in that command appears in the failure text. The 400-character cap bounds the exposure but does not redact it.The
Safe valuesrule indocs/internals/effect-services.mddoes not cover this message. It applies toSchema.TaggedErrorattributes and log annotations, and the repository guidance does not prescribe result-classification behavior for adapters. The concern rests on the disclosure itself, not on that rule.Choose a remedy that keeps the denied action identifiable without copying raw command text. The current prompt-based fallback in the approval path already exposes command text, so a change here should match the intended user-facing behavior. Do not reduce the message to tool names alone without deciding whether that still meets the PR goal of identifying the denied calls.