fix(acp): correct Claude refusal attribution - #774
Conversation
Codex ReviewVerdict: needs changes [P2] Normalize refusals across streamed message chunkssrc/main/acp/runtime-events.ts:134 Impact: If the provider splits the Claude refusal prefix across chunks, no chunk matches the full prefix and the final visible message still exposes Claude Code attribution. Recommendation: Normalize at the message-stream boundary or retain minimal per-message prefix state; add a split-prefix regression test. Summary: Static inspection found one user-visible streaming edge case: refusal normalization matches each ACP chunk independently, so a prefix split across valid chunks is not rewritten after reassembly. |
|
Thanks. I traced the refusal producer in the pinned Adding per-message buffering would introduce delayed output plus flush and lifecycle state for an input the current producer cannot emit, so the exact per-chunk normalization is intentionally kept stateless. |
fab8b41 to
24495b4
Compare
|
Rebased onto the latest |
Codex ReviewVerdict: needs changes [P2] Normalize refusals across streamed message chunkssrc/main/acp/runtime-events.ts:134 Impact: The check is performed independently on each Recommendation: Normalize after assembling the complete assistant message by Summary: Static review found one concrete stream-handling defect in the refusal normalization. |
|
Addressed in This keeps the producer fast path while avoiding per-message buffering or lifecycle state. Validation: 124 targeted tests, Node/Web typechecks, lint with 0 errors, formatting, and the full portable suite with 11,385 tests passed. |
Codex ReviewVerdict: mergeable No actionable findings. Summary: No concrete merge-blocking defects found. Branch and pull request title prechecks passed. |
Problem
A live Claude Code session using a custom Anthropic-compatible provider completed two native
WebSearchcalls and produced a useful partial answer, then ended withstopReason: "refusal". Claude Code appended fixed Anthropic AUP wording, misleadingly attributing the selected provider refusal to Anthropic.Proposed change
Replace only the fixed Claude Code AUP prefix with provider-neutral wording while normalizing visible ACP assistant events. Scope the rewrite to Claude Code sessions and preserve the remaining message, tool results, partial answer, and actual stop reason.
Scope and non-goals
Acceptance criteria and validation
All checks below ran after the last material source edit.
npm test -- src/main/acp/runtime-events.test.ts src/main/acp/session-update-projector.test.ts— 25 passednpm run typecheck:node— passednpm run lint— passed with 0 errors and 17 pre-existing warnings outside changed filesnpm test— 767 files passed, 14 skipped; 11,359 tests passed, 184 skippedRenderer consumer coverage is excluded because the event shape is unchanged; only an exact assistant-text prefix is normalized. Platform/E2E lanes are excluded because the change does not touch platform-specific behavior, persistence, or build configuration.
Known residual risk: if Claude Code changes its refusal wording, exact-prefix normalization intentionally stops matching until the prefix is updated.
Review focus
Please verify exact-prefix matching, Claude-only routing, and preservation of user/non-Claude messages.