Skip to content

Commit 143dd8a

Browse files
committed
fix(session-recovery): improve error detection and add continue prompt
- Enhance error type detection for thinking block order issues - Add continue prompt after successful session recovery - Improve error message matching logic
1 parent 36169c8 commit 143dd8a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/hooks/session-recovery.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ function detectErrorType(error: unknown): RecoveryErrorType {
7070
return "tool_result_missing"
7171
}
7272

73-
if (message.includes("thinking") && message.includes("first block")) {
73+
if (
74+
message.includes("thinking") &&
75+
(message.includes("first block") || message.includes("must start with") || message.includes("preceeding"))
76+
) {
7477
return "thinking_block_order"
7578
}
7679

src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,15 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
136136
sessionID,
137137
error,
138138
}
139-
await sessionRecovery.handleSessionRecovery(messageInfo)
139+
const recovered = await sessionRecovery.handleSessionRecovery(messageInfo)
140+
141+
if (recovered && sessionID && sessionID === mainSessionID) {
142+
await ctx.client.session.prompt({
143+
path: { id: sessionID },
144+
body: { parts: [{ type: "text", text: "continue" }] },
145+
query: { directory: ctx.directory },
146+
}).catch(() => {})
147+
}
140148
}
141149

142150
if (sessionID && sessionID === mainSessionID) {

0 commit comments

Comments
 (0)