Skip to content

Commit 221c6dc

Browse files
fix(telemetry): fix tool call status logic and remove unused import
- Fix tool call status: now properly detects error state - Remove unused Bus import from collector.ts
1 parent a62c89e commit 221c6dc

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

packages/opencode/src/telemetry/collector.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
import { Log } from "../util/log"
9-
import { Bus } from "../bus"
109
import { Config } from "../config/config"
1110
import { createSanitizer, hashFilePath, getFileExtension } from "./sanitizer"
1211
import { createSignalTracker, type SignalTracker } from "./signals"

packages/opencode/src/telemetry/integration.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,18 @@ function subscribeToEvents(state: TelemetryState): void {
152152
Bus.subscribe(MessageV2.Event.PartUpdated, (event) => {
153153
const { part } = event.properties
154154

155-
// Handle tool calls
156-
if (part.type === "tool" && part.state === "completed") {
155+
// Handle completed tool calls
156+
if (part.type === "tool" && (part.state === "completed" || part.state === "error")) {
157157
const duration = part.time?.end && part.time?.start ? part.time.end - part.time.start : 0
158+
const status = part.state === "completed" ? "success" : "error"
158159

159160
collector.recordToolCall(
160161
part.tool,
161-
part.state === "completed" ? "success" : "error",
162+
status,
162163
duration,
163164
part.input ? JSON.stringify(part.input).length : undefined,
164165
part.output ? part.output.length : undefined,
165-
undefined, // errorType - would need to parse from output
166+
status === "error" ? "tool_error" : undefined,
166167
)
167168
}
168169

0 commit comments

Comments
 (0)