Skip to content

fix(session-analysis): recognize lowercase edit tool names from Pi sessions - #157

Merged
phodal merged 1 commit into
QoderAI:mainfrom
chenzier:fix/pi-edit-tool-name-case
Sep 8, 2026
Merged

phodal merged 1 commit into
QoderAI:mainfrom
chenzier:fix/pi-edit-tool-name-case

Conversation

@chenzier

@chenzier chenzier commented Sep 8, 2026

Copy link
Copy Markdown

Why

Pi's coding agent emits lowercase tool names (edit, write), but edit-event detection in episode-contract.mjs and insights.mjs matched Claude Code's capitalized names (Edit, Write) with a case-sensitive Set lookup:

const EDIT_TOOL_NAMES = new Set(["Edit", "MultiEdit", "NotebookEdit", "Write"]);
// ...
return targetPaths.length > 0 && EDIT_TOOL_NAMES.has(event?.toolName);  // "edit" never matches

Every Pi edit event was therefore missed, which surfaces as withChanges: 0 in session facts for any Pi workspace that demonstrably has commits — meaning Task-Episode change evidence, change-gap classification, and read-only-work correction are all broken for the pi platform.

Notably, the same function already lowercases its input for PATHLESS_EDIT_TOOL_NAMES (apply_patch), so case-insensitive matching is the established intent here; the main set just never got the same treatment.

What changed

  • scripts/session-analysis/episode-contract.mjs: EDIT_TOOL_NAMES entries stored lowercase; isEditEvent compares against String(toolName ?? "").toLowerCase()
  • scripts/session-analysis/insights.mjs: same fix for its local EDIT_TOOL_NAMES copy, plus null-safe tool-name access

No behavior change for capitalized providers: "Edit".toLowerCase() still matches, and the match set strictly grows.

Validation

Reran session-analysis facts --platform pi over a 254-session workspace before/after:

metric before after
populationCoverage.withChanges 0 29
candidate class change-gap 0 11
candidate class read-only-work 44 21
candidateEpisodes 47 53

The workspace had ~500 commits in the analyzed window, so withChanges: 0 was provably a detection failure, not a read-only window.

Backward compatibility: the existing session-episode-contract and lifecycle-demand-signals tests (28 tests, all using capitalized Claude tool names) pass unchanged, and a spot check against a real Claude session (Write tool calls) confirms isEditEvent still returns true for capitalized names while Bash/Read stay false.

…ssions

Pi's coding agent emits lowercase tool names (edit, write), while the
edit-event detection in episode-contract and insights matched Claude
Code's capitalized names (Edit, Write) with a case-sensitive Set lookup.
Every Pi edit event was therefore missed, which surfaced as
withChanges: 0 in session facts for any workspace with real commits.

Store the edit tool names lowercase and compare against the lowercased
tool name, matching the existing case-insensitive check used for
PATHLESS_EDIT_TOOL_NAMES in the same function.

Validation: reran session-analysis facts --platform pi over a 254-session
workspace; populationCoverage.withChanges moved 0 -> 29, candidate
classes gained change-gap 11, and read-only-work dropped 44 -> 21 as
editing episodes were no longer misclassified. The existing episode
contract and lifecycle signal tests (28 tests, all using capitalized
Claude tool names) pass unchanged, confirming backward compatibility.
@phodal
phodal merged commit e11eaa8 into QoderAI:main Sep 8, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants