restart orphans tool use

This commit is contained in:
Ian Gulliver
2026-10-17 15:23:29 -07:00
parent 8f4251926d
commit 702ce49ff1
2 changed files with 11 additions and 4 deletions
+10 -3
View File
@@ -522,6 +522,12 @@ final class TranscriptBuilder {
}
}
private func endTools() {
for row in ctx.tools.values where row.result == nil && !(row.active || row.inActive) {
row.unfinished = true
}
}
private func renderToolCall(_ p: JSONDict) -> Row {
let row = Row(.tool(name: toolLabel(jsString(p["name"])), brief: toolBrief(p["input"] ?? nil, worktree()), input: prettyJSON(p["input"] ?? nil)), taskId: taskId)
row.tag = subagentTag(parentOf(p))
@@ -552,6 +558,9 @@ final class TranscriptBuilder {
switch ev.kind {
case "user.message":
ctx.quiet = false
if !bool(p, "mid_turn") {
endTools()
}
let text = str(p, "text") ?? ""
if ev.actor == "byre" {
let first = text.components(separatedBy: "\n").first ?? ""
@@ -591,9 +600,7 @@ final class TranscriptBuilder {
return nil
case "turn.ended":
for row in ctx.tools.values where row.result == nil && !(row.active || row.inActive) {
row.unfinished = true
}
endTools()
if bool(p, "handoff") {
return note([.text("handoff written; continuing in a new session with a fresh context")])
}