Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions STATS.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,9 @@
| 2025-09-13 | 324,894 (+3,848) | 245,539 (+4,811) | 570,433 (+8,659) |
| 2025-09-14 | 328,876 (+3,982) | 248,245 (+2,706) | 577,121 (+6,688) |
| 2025-09-15 | 334,201 (+5,325) | 250,983 (+2,738) | 585,184 (+8,063) |
| 2025-09-16 | 342,613 (+8,412) | 255,264 (+4,281) | 597,877 (+12,693) |
| 2025-09-17 | 351,118 (+8,505) | 260,970 (+5,706) | 612,088 (+14,211) |
| 2025-09-18 | 358,718 (+7,600) | 266,922 (+5,952) | 625,640 (+13,552) |
| 2025-09-19 | 365,402 (+6,684) | 271,859 (+4,937) | 637,261 (+11,621) |
| 2025-09-20 | 372,092 (+6,690) | 276,917 (+5,058) | 649,009 (+11,748) |
| 2025-09-21 | 377,083 (+4,991) | 280,261 (+3,344) | 657,344 (+8,335) |
2 changes: 1 addition & 1 deletion packages/opencode/src/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export namespace Session {
let sum = 0
for (let msgIndex = msgs.length - 2; msgIndex >= 0; msgIndex--) {
const msg = msgs[msgIndex]
if (msg.info.role === "assistant" && msg.info.summary) return
if (msg.info.role === "assistant" && msg.info.summary && !msg.info.error) return
for (let partIndex = msg.parts.length - 1; partIndex >= 0; partIndex--) {
const part = msg.parts[partIndex]
if (part.type === "tool")
Expand Down
2 changes: 1 addition & 1 deletion packages/opencode/src/session/message-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ export namespace MessageV2 {
}

export function filterSummarized(msgs: { info: MessageV2.Info; parts: MessageV2.Part[] }[]) {
const i = msgs.findLastIndex((m) => m.info.role === "assistant" && !!m.info.summary)
const i = msgs.findLastIndex((m) => m.info.role === "assistant" && !!m.info.summary && !m.info.error)
if (i === -1) return msgs.slice()
return msgs.slice(i)
}
Expand Down
15 changes: 14 additions & 1 deletion packages/opencode/src/tool/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,25 @@ export const TaskTool = Tool.define("task", async () => {
],
})
unsub()
const outputText = (result.parts.findLast((x: any) => x.type === "text") as any)?.text ?? ""
const err = (result as any).info?.error
if (err) {
const isAborted = MessageV2.AbortedError.isInstance(err)
const name = typeof err === "object" && err && "name" in err ? (err as any).name : "Error"
const msg =
typeof err === "object" && err && "data" in err && (err as any).data && "message" in (err as any).data
? ((err as any).data as any).message
: name
const partial = outputText ? `\nPartial output from subagent before interruption:\n${outputText}` : ""
const text = isAborted ? `Subagent task was interrupted by user.` : `Subagent encountered an error: ${msg}`
throw new Error(`${text}${partial}`)
}
return {
title: params.description,
metadata: {
summary: result.parts.filter((x: any) => x.type === "tool"),
},
output: (result.parts.findLast((x: any) => x.type === "text") as any)?.text ?? "",
output: outputText,
}
},
}
Expand Down