Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/domain/analysisErrorPresentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ export const analysisErrorRemediationAction = (
return error.remediationAction;
if (error instanceof UnknownRegistryError && error.reason === "not-found")
return "Check that the unknown_id belongs to this session, then retry.";
if (
UNREADABLE_OUTPUT_TAGS.has(error._tag) ||
ADAPTER_FAILURE_TAGS.has(error._tag)
Comment thread
prabhuramkarki marked this conversation as resolved.
Resolved
)
return "Run `rea doctor` and review the reported details to correct the request or provider setup before running the analysis again.";
if (CANCELLED_TAGS.has(error._tag))
return "Start the analysis again when ready.";
if (TIMEOUT_TAGS.has(error._tag))
return "Narrow the request, then run `rea doctor` if it still exceeds its deadline.";
return analysisErrorUserMessage(error);
};

Expand Down
40 changes: 40 additions & 0 deletions src/domain/analysisErrorProjection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
AnalysisCancelledError,
AnalysisTimeoutError,
AnalysisResourceConstraintError,
AnalysisProtocolError,
} from "./analysisErrorCore.js";
import { ArtifactOperationError } from "./artifactOperationError.js";
import { BinaryTargetError } from "./configurationErrors.js";
Expand All @@ -17,6 +18,8 @@ import {
HopperRemoteError,
HopperStartError,
HopperTimeoutError,
HopperCancelledError,
HopperProtocolError,
} from "./hopperErrors.js";
import { ProviderAdapterError } from "./providerAdapterError.js";
import { UnknownRegistryError } from "./unknownRegistryError.js";
Expand Down Expand Up @@ -573,6 +576,43 @@ describe("analysis error projection: Hopper startup failures", () => {
});

describe("analysis error projection: retry guidance", () => {
it.each([
new AnalysisProtocolError("invalid reply"),
new AnalysisOutputError("inspect", "report missing"),
new HopperProtocolError("invalid reply"),
new ProviderAdapterError("fixture", "inspect"),
new AnalysisCancelledError("inspect"),
new HopperCancelledError(),
new AnalysisTimeoutError("inspect", 30),
])("separates recovery actions from the $_tag failure message", (error) => {
const projected = projectAnalysisError(error);
expect(projected.remediation.action).not.toBe(projected.message);
expect(projected.remediation.action).toMatch(/^(Run|Start|Narrow)\b/u);
expect(analysisErrorProjectionSchema.safeParse(projected).success).toBe(
true,
);
});

it.each([
new ProviderAdapterError("fixture", "inspect", {
userMessage: "Selected provider failed.",
remediationAction: "Correct the selected provider setting.",
}),
new AnalysisOutputError("inspect", "report missing", {
userMessage: "Selected report is incomplete.",
remediationAction: "Select a complete report.",
}),
new AnalysisTimeoutError("inspect", 30, {
userMessage: "Selected deadline elapsed.",
remediationAction: "Increase the selected operation deadline.",
}),
])("preserves producer recovery guidance for $_tag", (error) => {
expect(projectAnalysisError(error)).toMatchObject({
message: error.userMessage,
remediation: { action: error.remediationAction },
});
});

it.each([
[
"unreadable output",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ describe("enhanced MCP batches", () => {
retryable: false,
remediation: {
action:
"Analysis returned an unreadable result. Run `rea doctor` and review the reported details; repeating the unchanged request is not expected to succeed.",
"Run `rea doctor` and review the reported details to correct the request or provider setup before running the analysis again.",
},
},
},
Expand Down
Loading