Skip to content

Commit 8918a65

Browse files
shivamhwpPR Batch Testerclaude
authored
fix(provider): show exit details when ACP session startup crashes (#28419)
Co-authored-by: PR Batch Tester <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent f460136 commit 8918a65

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

‎packages/provider-core/src/server/failure.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
NodeId,
44
ProviderDriverKind,
55
ProviderInstanceId,
6+
ProviderSessionId,
67
ProviderSetupError,
78
ProviderThreadId,
89
ProviderTurnId,
@@ -14,6 +15,7 @@ import * as DateTime from "effect/DateTime";
1415
import * as Effect from "effect/Effect";
1516

1617
import {
18+
knownProviderFailureMessage,
1719
makeProviderFailure,
1820
makeProviderFailureTurnItem,
1921
MAX_PROVIDER_FAILURE_MESSAGE_LENGTH,
@@ -106,6 +108,37 @@ it("preserves actionable T3 errors wrapped by turn startup", () => {
106108
}
107109
});
108110

111+
it("names how the provider process exited and the stage it failed in, without its output", () => {
112+
for (const [exit, status] of [
113+
[{ signal: "SIGILL" }, " after signal SIGILL"],
114+
[{ code: 134 }, " with code 134"],
115+
[{}, ""],
116+
[{ signal: "SIGILL Bearer signal-secret" }, ""],
117+
] as const) {
118+
const sessionOpenFailure = {
119+
_tag: "ProviderSessionOpenError",
120+
cause: new ProviderAdapter.ProviderAdapterOpenSessionError({
121+
driver: ProviderDriverKind.make("antigravity"),
122+
providerSessionId: ProviderSessionId.make("provider-session:private-id"),
123+
cause: {
124+
_tag: "AcpProcessExitedError",
125+
...exit,
126+
pid: 4242,
127+
stderr: "*** SIGILL *** token=stderr-secret",
128+
cause: new Error("Process interrupted with private-detail"),
129+
},
130+
}),
131+
};
132+
const expected = `The provider session could not be opened: the provider process exited${status}. Check the server logs for the provider's output, then retry the turn.`;
133+
assert.equal(knownProviderFailureMessage(sessionOpenFailure), expected);
134+
assert.equal(makeProviderFailure({ cause: Cause.fail(sessionOpenFailure) }).message, expected);
135+
}
136+
assert.equal(
137+
makeProviderFailure({ cause: { _tag: "AcpProcessExitedError", code: 1 } }).message,
138+
"The provider process exited with code 1. Check the server logs for the provider's output, then retry the turn.",
139+
);
140+
});
141+
109142
it("keeps unrecognized reasons and provider text out of category messages", () => {
110143
for (const cause of [
111144
"Private launch command",

‎packages/provider-core/src/server/failure.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ function curatedCauseMessages(cause: unknown): {
110110
case "CursorModelUnavailableError":
111111
case "ProviderSetupError":
112112
return { known: stringField(cause, "message"), category: categoryMessage() };
113+
case "AcpProcessExitedError": {
114+
const exit = `provider process exited${processExitStatus(cause)}`;
115+
const stage = category === undefined ? `The ${exit}` : `${category.summary}: the ${exit}`;
116+
return {
117+
known: `${stage}. Check the server logs for the provider's output, then retry the turn.`,
118+
category: categoryMessage(),
119+
};
120+
}
113121
case "ContextHandoffDeliveryUncertainError":
114122
return {
115123
known:
@@ -140,6 +148,15 @@ function curatedCauseMessages(cause: unknown): {
140148
return { known: undefined, category: categoryMessage() };
141149
}
142150

151+
// Only the structured status; stderr and the spawner cause can carry provider output.
152+
function processExitStatus(exited: object): string {
153+
const { signal, code } = exited as Record<string, unknown>;
154+
if (typeof signal === "string" && /^SIG[A-Z0-9]{1,16}$/u.test(signal)) {
155+
return ` after signal ${signal}`;
156+
}
157+
return typeof code === "number" && Number.isSafeInteger(code) ? ` with code ${code}` : "";
158+
}
159+
143160
/**
144161
* The curated message of a domain error in a failure's cause chain, if any.
145162
* Callers that pass their own `message` to `makeProviderFailure` check it

0 commit comments

Comments
 (0)