Skip to content

fix(parser): detect opencode invalid tool calls as failures - #1255

Merged
mjacobs merged 4 commits into
kenn-io:mainfrom
ajinkyajacob:fix/opencode-invalid-tool-failure-detection
Jul 24, 2026
Merged

fix(parser): detect opencode invalid tool calls as failures#1255
mjacobs merged 4 commits into
kenn-io:mainfrom
ajinkyajacob:fix/opencode-invalid-tool-failure-detection

Conversation

@ajinkyajacob

Copy link
Copy Markdown
Contributor

Fixes #1254

Problem

Opencode stores failed tool calls with tool: "invalid" and state.status: "completed" — the parser never emitted a ResultEvent, so ComputeToolHealth had no error signal to detect. All opencode sessions showed tool_failure_signal_count: 0 despite confirmed invalid tool calls.

Fix

In extractOpenCodeToolCall(), when d.ToolName == "invalid", attach a ResultEvent{Status: "errored"} so the signal pipeline (extractToolCallRowssignals.IsFailureComputeToolHealth) counts it as a failure.

Test

Added TestParseOpenCodeDB_InvalidToolCall that seeds a session with an invalid tool part and asserts ResultEvents[0].Status == "errored".

All existing opencode tests continue to pass.

Opencode stores failed tool calls as type:'tool' with tool:'invalid'
and state.status:'completed' — the existing parser never emitted a
ResultEvent, so ComputeToolHealth had no error signal to detect.

When tool == 'invalid', attach a ResultEvent with Status:'errored'
so extractToolCallRows → signals.IsFailure → ComputeToolHealth
counts it as a failure signal.

Fixes kenn-io#1254
@roborev-ci

roborev-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown

roborev: Combined Review (70581d9)

The change is sound overall, but it needs a data-version bump to apply correctly to previously synced sessions.

Medium

  • internal/db/db.go:324 — The parser now persists additional result events, but dataVersion remains 71. Previously synced, unchanged OpenCode sessions will be skipped, so their historical invalid calls will not be recognized as failures.
    • Fix: Bump and document the data version, then update the corresponding version assertion to trigger a non-destructive resync.

Reviewers: 2 done | Synthesis: codex, 7s | Total: 2m24s

mjacobs added 3 commits July 24, 2026 10:24
Previously synced OpenCode sessions were parsed before the invalid-tool
failure fix and carry no errored result events. Bumping the data version
triggers the non-destructive resync so historical invalid calls count as
failures.
@roborev-ci

roborev-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown

roborev: Combined Review (993a978)

Code review passed: no Medium, High, or Critical findings.


Reviewers: 2 done | Synthesis: codex, 6s | Total: 2m39s

@mjacobs
mjacobs merged commit 8aa989f into kenn-io:main Jul 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Support opencode tool failure detection (tool: invalid format)

2 participants