Skip to content

Commit f4a5cc7

Browse files
Anand Guptaclaude
authored andcommitted
revert(session): drop the stalled-step replay exception
The replay of an errored assistant step is a pre-existing limitation for every error, and handling it correctly (per-part filtering, all retryable errors, errored tools) is a separate change. Keep this PR to stall detection and the retry rules; the known limit is documented in the PR. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 2613ba5 commit f4a5cc7

2 files changed

Lines changed: 2 additions & 71 deletions

File tree

‎packages/opencode/src/session/message-v2.ts‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -763,22 +763,15 @@ export namespace MessageV2 {
763763
const differentModel = `${model.providerID}/${model.id}` !== `${msg.info.providerID}/${msg.info.modelID}`
764764
const media: Array<{ mime: string; url: string }> = []
765765

766-
// altimate_change start — a stalled step whose retry was refused keeps the results of tools that actually
767-
// completed in replay, so the next turn knows those side effects happened. Partial text or tool input that
768-
// never ran is not replayed.
769766
if (
770767
msg.info.error &&
771768
!(
772-
(MessageV2.AbortedError.isInstance(msg.info.error) &&
773-
msg.parts.some((part) => part.type !== "step-start" && part.type !== "reasoning")) ||
774-
(MessageV2.APIError.isInstance(msg.info.error) &&
775-
msg.info.error.data.message.startsWith(ProviderError.MODEL_STOPPED_RESPONDING) &&
776-
msg.parts.some((part) => part.type === "tool" && part.state.status === "completed"))
769+
MessageV2.AbortedError.isInstance(msg.info.error) &&
770+
msg.parts.some((part) => part.type !== "step-start" && part.type !== "reasoning")
777771
)
778772
) {
779773
continue
780774
}
781-
// altimate_change end
782775
const assistantMessage: UIMessage = {
783776
id: msg.info.id,
784777
role: "assistant",

‎packages/opencode/test/session/message-v2.test.ts‎

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,68 +1054,6 @@ describe("session.message-v2.toModelMessage", () => {
10541054
])
10551055
})
10561056

1057-
test("replays a stalled step only when a tool actually completed in it", async () => {
1058-
const withTool = "m-assistant-stalled"
1059-
const textOnly = "m-assistant-text"
1060-
const pendingTool = "m-assistant-pending"
1061-
const stalled = new SessionV1.APIError({
1062-
message:
1063-
"The model stopped responding: no response headers within 300s (not retried: the attempt had already acted: echo)",
1064-
isRetryable: true,
1065-
}).toObject() as SessionV1.Assistant["error"]
1066-
1067-
const input: SessionV1.WithParts[] = [
1068-
{
1069-
info: assistantInfo(withTool, "m-parent", stalled),
1070-
parts: [
1071-
{
1072-
...basePart(withTool, "a1"),
1073-
type: "tool",
1074-
callID: "call-1",
1075-
tool: "echo",
1076-
state: {
1077-
status: "completed",
1078-
input: { cmd: "rm" },
1079-
output: "ran rm",
1080-
title: "echo",
1081-
metadata: {},
1082-
time: { start: 0, end: 1 },
1083-
},
1084-
},
1085-
] as SessionV1.Part[],
1086-
},
1087-
{
1088-
info: assistantInfo(textOnly, "m-parent", stalled),
1089-
parts: [{ ...basePart(textOnly, "b1"), type: "text", text: "half an answ" }] as SessionV1.Part[],
1090-
},
1091-
{
1092-
info: assistantInfo(pendingTool, "m-parent", stalled),
1093-
parts: [
1094-
{
1095-
...basePart(pendingTool, "c1"),
1096-
type: "tool",
1097-
callID: "call-2",
1098-
tool: "echo",
1099-
state: {
1100-
status: "error",
1101-
input: {},
1102-
error: "Tool execution aborted",
1103-
metadata: { interrupted: true },
1104-
time: { start: 0, end: 1 },
1105-
},
1106-
},
1107-
] as SessionV1.Part[],
1108-
},
1109-
]
1110-
1111-
const out = await MessageV2.toModelMessages(input as unknown as MessageV2.WithParts[], model)
1112-
const text = JSON.stringify(out)
1113-
expect(text).toContain("ran rm")
1114-
expect(text).not.toContain("half an answ")
1115-
expect(text).not.toContain("Tool execution aborted")
1116-
expect(out.filter((m) => m.role === "assistant")).toHaveLength(1)
1117-
})
1118-
11191057
test("preserves OpenRouter reasoning details through provider transform", async () => {
11201058
const assistantID = "m-assistant"
11211059
const openrouterModel: Provider.Model = {

0 commit comments

Comments
 (0)