Skip to content

fix(dash): count every call, so a called tool is never "unused" - #733

Merged
vz-ibm merged 2 commits into
mainfrom
fix/tool-calls-match-last-used
Oct 26, 2026
Merged

vz-ibm merged 2 commits into
mainfrom
fix/tool-calls-match-last-used

Conversation

@vz-ibm

@vz-ibm vz-ibm commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

A tool's call count and its last-used time disagreed in /api/tools. A server row could show calls: 0 while its tool showed a last-used time. calls: 0 is what files a tool as never used, so the report could suggest removing a tool the user had called. This PR makes the call count include every call in scope, as last-used already does.

What we found

  • lastUsedOf reads every session in scope.
  • buildToolReport added a call to Calls only in a session that also declared the tool (usedIn[dr.session][k]).
  • So a call made in a session with no declaration row for the tool set last_used and left calls at 0. That happens when the tool was deferred and not yet recorded (see fix(dash): record deferred MCP tools in the tool inventory #728), or when the session began before the proxy.

Found while testing #728: after calling mcp__context7__resolve-library-id, the context7 server row read calls: 0 while last-used showed the call.

What changed

  1. buildToolReport: Calls is the total over every session in scope, the same set lastUsedOf reads. SessionsUsed and the unused figures stay per session. A session that carried a tool without calling it still paid for it, so its cost is unchanged.
  2. Three more places used the narrow rule. Each now uses the verdict's own test of "invoked", SessionsUsed > 0 || Calls > 0, which insightsshape.go already uses:
    • suggest (toolfilter suggestions): a called tool is never suggested for removal. Before, it could be.
    • serverRollup: ToolsUsed counts a called tool.
    • The skills summary: Invoked and Calls count a called skill.

/api/adapt/tools already counted every call (usedTool[u.name] over all uses) and is unchanged.

How it was tested

Five new tests in dash/toolapi_calls_test.go. Each failed first for the intended reason:

  • TestCallsCountEveryCallInScope: was calls=0 last_used=20. It also checks that SessionsUsed stays 0, and that the unused carry of the declaring session stays.
  • TestCallsInADeclaringSessionAreNotDoubleCounted: the control. It passed before and after.
  • TestSkillsSummaryCountsACallWithoutADeclaringSession: was invoked=0 calls=0.
  • TestServerRollupCountsACalledTool: was ToolsUsed: 0.
  • TestSuggestNeverOffersACalledTool: it suggested removing a tool that was called.

Suites:

  • go build ./... and make lint: clean.
  • go test ./dash/... ./proxy/...: all pass except TestCalculatorPricesFromTheRowsModelNotABlend, which also fails on clean main on this machine. No existing test changed its result.

Data dependence

  • No change to what any component or feature stores.

This PR changes only how stored rows are counted on read. It stores nothing new.

What it does at each level (see docs/data-dependence.md):

  • Off: no change.
  • Metadata only: works. It reads the same tool_uses and tool_declarations rows.
  • Everything: works, as for metadata only.

Open questions

  1. Imported history still does not count. Imported request rows have Tools = 0, and scopedUses keeps only sessions with r.tools > 0. So a skill used only before install keeps calls == 0. The plugin warns ("used Nd ago - check first") but still lists it. TestAnImportedInvocationStopsTheRemovalAdvice, which names this behaviour, skips every time, so it never asserts it. A follow-up can count imported uses too.
  2. fix(dash): record deferred MCP tools in the tool inventory #728 overlap: fix(dash): record deferred MCP tools in the tool inventory #728 also edits dash/toolapi.go (toolReportFor, deferredNames). This PR edits only buildToolReport, serverRollup and suggest. I expect no conflict.

Assisted-By: Claude (Anthropic AI) [email protected]

A tool's call count and its last-used time disagreed: the server row
showed calls: 0 while last_used showed the call. lastUsedOf reads every
session in scope; Calls counted a call only in a session that also
declared the tool. A call made where the tool had no declaration row
(deferred, or a session that began before the proxy) therefore set
last_used and left calls at 0. Calls 0 files a tool as never used, so the
report could suggest removing a tool the user had called.

- buildToolReport: Calls is the total over every session in scope, the
  same set lastUsedOf reads. SessionsUsed and the unused figures stay
  per session: a session that carried a tool without calling it still
  paid for it.
- The skills summary, the server rollup's ToolsUsed and the toolfilter
  suggestion use the verdict's own test of "invoked"
  (SessionsUsed > 0 || Calls > 0). A called tool is never suggested.

/api/adapt/tools already counted every call and is unchanged.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @vz-ibm) Claude Code 2.1.310 offload-review skill, @vz-ibm's session fresh 2 of 2 1 of 2 5387d77b5e6e blocking

Verdict: blocking

The Go change is correct. Calls now agrees with last_used, and nothing is double counted. But the dashboard UI and one Go counter still use the old test of "used" (sessions_used only). So the dashboard still tells the user to remove a tool they called. That is the defect this PR says it fixes.

Findings

  1. dash/ui/tools.js:2312-2314 (and 574-576) — the Tools tab still lists a called tool as removable, with a command to paste

    • What fails: take the PR's own case. context7 tool is declared only in s2 and called only in s1. After this PR the row has calls: 2, sessions_used: 0, sessions_declared: 1, and unused_reads > 0 (the s2 carry). removableRows keeps it because !t.sessions_used is true. The row then goes into groupRemovable → renderInvTop and ctaBlock, so the user gets a "remove this" card and a paste-able claude mcp remove / settings snippet. renderUnused (line 575) uses the same filter.
    • Proof: removableRows filter is !t.sessions_used && t.sessions_declared > 0 && !t.builtin && t.kind !== 'server_tool'. It never reads t.calls. renderInventory (line 2286) passes these rows to the top cards and to ctaBlock (line 2295).
    • Fix: use the same test as the Go side: !t.sessions_used && !t.calls && ... in both filters. Also lines 1254/1258 and 1376/1383 mark the row cg-row-unused and show the "never" pill next to a non-zero Calls cell. Use the same test there, or show the call count.
  2. dash/ui/app.js:1825 — the Overview "remove" list still recommends a called skill

    • What fails: the PR's skill case (dataviz declared in s2, called in s1). The skill row has sessions_used: 0 and unused_usd > 0 from the s2 carry. The Overview filter t.sessions_used === 0 && t.unused_usd > 0 keeps it, so the Overview card says to remove a skill the user ran. The server line above it (line 1823) is now right, because it reads tools_used, which this PR fixed.
    • Proof: line 1825 reads only sessions_used and unused_usd. Neither changes in this PR, by design (the commit keeps them per session).
    • Fix: add && !t.calls to the skills filter.
  3. dash/toolsuggest.go:442 — Withheld still counts a called item as "never used"

    • What fails: a called tool with SessionsUsed == 0 now fails suggest (correct). The else if st.SessionsUsed == 0 && st.Tokens > 0 branch then adds it to Withheld. The field's own doc (line 386) says it counts "never-used items" that did not reach the bar. So the toolfilter doc tells the reader that more never-used items exist than do.
    • Proof: suggest at line 527 now rejects on st.Calls > 0. Line 442 does not have the same clause.
    • Fix: else if st.SessionsUsed == 0 && st.Calls == 0 && st.Tokens > 0. Add one assertion on Withheld to TestSuggestNeverOffersACalledTool, or a test through ToolFilterDocFor.

Non-blocking

  • dash/insightsshape.go:428 — verdictFor for an item invoked only through calls now says "invoked in 0 sessions — it earns the weight it carries". This path existed before (the || r.Calls > 0 was already there), but this PR makes it common. Quote the call count when SessionsUsed == 0, as insights.py:1301 does.
  • dash/toolapi_calls_test.go:47-51 — TestCallsInADeclaringSessionAreNotDoubleCounted passes when the tool is missing from rep.Tools. Assert that the row was found, as the first test does.
  • No test covers the UI filters. There are no JS tests in dash/ui, so a Go-side test cannot catch findings 1 and 2. Consider one Playwright or unit check, or state in the PR that the UI is unverified.
  • The PR text says "a called tool is never suggested". That is true for /api/toolfilter suggestions only. Findings 1 and 2 are other routes to the same advice.

What I checked

  • Read the full diff (3 files, +111/-3) and the commit message and PR body.
  • buildToolReport (dash/toolapi.go:787-1073): allCalls sums usedIn over every session, the same uses set that lastUsedOf reads. The per-declaration st.Calls += calls (line 881) is now overwritten, so no double count. SessionsUsed, UnusedReads, UnusedUSD, unusedTok and the per-session rows still use the per-session test, which matches the stated design.
  • stats holds only declared items, so the override never creates a row for an undeclared tool. The KindTool/KindMCPTool/KindSkill keys from usedBySession match the statKey of each declaration.
  • Skills summary (line 1012) and serverRollup (line 1143): the new test matches insightsshape.go:283/298. Skills.Calls only adds calls of an invoked skill, and every skill with calls is now invoked, so the total is consistent.
  • suggest (dash/toolsuggest.go:527): the new clause is correct. The test sets the window above suggestMinSessions/suggestMinSpan, so it fails only on Calls.
  • Every other reader of sessions_used / tools_used: dash/ui/tools.js, dash/ui/app.js, context-guru-plugin/scripts/insights.py (already uses calls or sessions_used, fine), dash/insightsshape.go.
  • carriedCost still keys on usedBySession per session (line 546). That is consistent with the per-session unused figures.
  • Fail open and reversibility: not touched. This is a read-side report change only. Data dependence: no change, as the PR says.
  • I did not run Go or the UI. Live tests are not approved.

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @vz-ibm) Claude Code 2.1.310 offload-review skill, @vz-ibm's session fresh 1 of 2 1 of 2 5387d77b5e6e blocking

Verdict: blocking

The Go fix in buildToolReport is correct. But it creates a new state: SessionsUsed == 0 && Calls > 0. Before this PR, that state could not occur, because Calls grew only together with SessionsUsed (old toolapi.go:879-881). The PR updates 3 consumers. Other consumers still test only sessions_used, so they still call a called tool "never used".

Findings

  1. dash/ui/tools.js:575, dash/ui/tools.js:2314, dash/ui/app.js:1825 — the dashboard still lists a called tool or skill as removable

    • What fails: use the PR's own test input. mcp__context7__resolve-library-id is declared only in s2 and called 2 times only in s1. /api/tools now returns calls: 2, sessions_used: 0, sessions_declared: 1, unused_usd > 0.
      • renderUnused (tools.js:574-576) keeps rows with !t.sessions_used && t.sessions_declared > 0. The tool shows in "Every removable group, with its evidence".
      • removableRows (tools.js:2312-2315) has the same filter. It feeds renderInvTop and groupRemovable (tools.js:2286-2288), so the Overview ranks the tool for removal.
      • app.js:1825 keeps skills with sessions_used === 0 && unused_usd > 0. The s2 carry gives unused_usd > 0, so a called skill is a top-5 "Recommendation" to remove.
      • The tool and skill tables (tools.js:1254-1259, 1376-1384, 1636-1637) mark the row cg-row-unused and print a "never" pill next to calls: 2.
    • Proof: the PR title is "a called tool is never 'unused'". The server panel at app.js:1823 now works, because tools_used moved. The per-row filters did not move, so the same tool is "used" in the server row and "removable" in the tool row.
    • Fix: use the same test as Go in each filter, for example !t.sessions_used && !t.calls. Make the "never" pill and the cg-row-unused class follow it too.
  2. dash/toolsuggest.go:442 — Withheld counts a called tool as a "never-used item below the bar"

    • What fails: suggest now refuses a tool with Calls > 0 (toolsuggest.go:527). Then the else if st.SessionsUsed == 0 && st.Tokens > 0 branch runs and does out.Withheld++. The field doc (toolsuggest.go:386) says Withheld counts "never-used items" that did not reach the bar. The plugin prints it as suggest_withheld (insights.py:772). So the report says "N items are not used yet, wait for more evidence", and N includes tools the user called.
    • Proof: same input as finding 1. suggest returns false on the st.Calls > 0 clause. st.SessionsUsed == 0 and st.Tokens == 9, so Withheld becomes 1. Before this PR, Calls was 0 for this tool, so it was a real never-used item. Now it is not.
    • Fix: else if st.SessionsUsed == 0 && st.Calls == 0 && st.Tokens > 0. Add a test with the PR's input that asserts Withheld == 0.
  3. dash/insightsshape.go:428 and context-guru-plugin/scripts/insights.py:1301 — the verdict text says "invoked in 0 sessions"

    • What fails: for the new state, verdictFor returns "invoked in 0 sessions — it earns the weight it carries". The plugin returns "invoked: 2 call(s) in 0 session(s), ...". Both are wrong evidence. This report claims that every why traces to a measurement.
    • Proof: invoked is true from r.Calls > 0 (insightsshape.go:298). plural(r.SessionsUsed, "session") with SessionsUsed == 0 gives "0 sessions" (insightsshape.go:443-448). This text was unreachable before this PR.
    • Fix: when SessionsUsed == 0, quote the calls, for example "called N times in sessions that did not declare it". Add one case to the insights shape test.

Non-blocking

  • dash/toolapi.go:881 — st.Calls += calls is now dead. The loop at 925-928 overwrites Calls for every stat. Remove it, or say in a comment that the later loop owns Calls.
  • dash/toolapi.go:916-924 — allCalls reads every session in usedIn. The declaration loop skips sessions with no sessions entry (line 806-808). Both come from the same scope today, so this is only a note.
  • dash/toolapi_calls_test.go:47-51 — TestCallsInADeclaringSessionAreNotDoubleCounted passes if the tool is missing from rep.Tools. Assert that the row was found, as the first test does.
  • ServerStat.SessionsUsed is the maximum of t.SessionsUsed (toolapi.go:1152-1154). It can now be 0 while the server's calls is above 0. The plugin prints both facts (insights.py:890-891). Not wrong, but a reader can be confused.

What I checked

  • The full diff (3 files) and the commit message of 5387d77. The PR body.
  • buildToolReport in full, usedBySession, lastUsedOf, scopedUses, serverRollup, suggest and the Withheld loop in ToolFilterDocFor.
  • That allCalls keys match the stat keys: usedBySession writes KindTool, KindMCPTool or KindServerTool, and KindSkill keys. Each stat has one kind, so no double count.
  • That SessionsUsed, UnusedReads, UnusedUSD and the totals stay per session. They do.
  • Every consumer of sessions_used / SessionsUsed and calls in dash/*.go, dash/ui/*.js and context-guru-plugin/scripts/insights.py.
  • The 5 new tests. I read them only. Live tests are not approved, so I did not run Go.
  • Data dependence: the PR reads the same rows and stores nothing new. No update to docs/data-dependence.md is needed.

Review round 1 on #733 (both reviewers): the Go side counted every call,
but the dashboard kept its own rule, `!t.sessions_used`. A tool called
in a session that did not declare it has sessions_used 0 and calls > 0,
so the UI still listed it as removable: a remove card with a command to
paste, a "never" pill, the unused row style, and an Overview top-5 entry.

- app.js: neverCalled(t), the server's own test (no sessions_used and no
  calls). Every unused filter, row class and pill in app.js and tools.js
  now uses it. TestTheDashboardUsesOneNeverCalledRule reads the source
  and fails if any of them tests sessions_used alone.
- ToolFilterDoc.Withheld no longer counts a called tool as a never-used
  item below the bar.
- The verdict text no longer says "invoked in 0 sessions" (Go) or
  "2 call(s) in 0 session(s)" (plugin): for a tool called only where it
  was not declared it quotes the calls.
- Removed the now-dead `st.Calls += calls`; the later loop owns Calls.
- The double-count control test now fails if its row is missing.

Live: on main the Overview told the user to remove context7 and dataviz,
which they had called; with this branch it lists only playwright.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
@vz-ibm

vz-ibm commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator Author

Reply to review round 1

Both reviewers blocked, with the same main finding. All fixed in a3f5525.

Finding: the dashboard still lists a called tool or skill as removable (both reviewers)

Correct. I fixed the Go side and missed that the UI repeats the rule in JavaScript, as !t.sessions_used.

Fixed with one rule. app.js now defines neverCalled(t) (!t.sessions_used && !t.calls), the same test as the server. All 8 places now use it:

  • renderUnused and removableRows (tools.js): the "Every removable group" list, the Overview ranking and ctaBlock.
  • The Overview skills filter (app.js:1825).
  • The cg-row-unused class (2 tables) and the "never" pill (3 tables).

Test: TestTheDashboardUsesOneNeverCalledRule reads the source. It checks that neverCalled tests both fields, and that no filter, row class or pill in app.js or tools.js tests sessions_used alone. It fails on the old UI.

Live check. I ran a proxy built from main (06b40ed) and one from this branch, over the same seeded database: context7 called 2 times and dataviz called 1 time, each in a session that did not declare them; playwright never called.

  • Overview "remove these": main lists context7, playwright and dataviz. This branch lists playwright only.
  • Inventory unused rows and "never" pills: main marks context7 and playwright. This branch marks playwright only.
  • No page errors on either build.

Finding: Withheld counts a called tool as never used (both reviewers)

Fixed. It now also requires Calls == 0. Test: TestWithheldDoesNotCountACalledTool, which runs through ToolFilterDocFor. It failed first with withheld = 1.

Finding: the verdict text says "invoked in 0 sessions" (reviewer 1; reviewer 2 non-blocking)

Fixed in both places. For a tool called only where it was not declared:

  • Go verdictFor: "called 2 times, in sessions that did not declare it — it earns the weight it carries".
  • Plugin _verdict: "invoked: 2 call(s), in sessions that did not declare it, so it earned …".

The Codex insights.py has no _verdict, so it needs no change. Tests: TestVerdictQuotesCallsWhenNoDeclaringSessionUsedIt (Go) and TestInsightsVerdictQuotesCallsWhenNoDeclaringSessionUsedIt (plugin, calls _verdict directly). Both failed first with the exact text in the reviews.

Non-blocking

  • Dead st.Calls += calls (reviewer 1). Removed. A comment now says the later loop owns Calls.
  • Control test passes when its row is missing (both). Fixed: it now fails if the row is missing.
  • allCalls reads sessions outside sessions (reviewer 1). No change. Both come from the same scope query today, as the reviewer notes.
  • ServerStat.SessionsUsed can be 0 while calls > 0 (reviewer 1). No change. Both facts are true, and the verdict text now explains the case.
  • No UI test (reviewer 2). Partly closed by the source test above. The browser behaviour is checked live (above), not by CI on this branch.

Checks

  • go build ./... and make lint: clean.
  • go test ./dash/... ./proxy/...: all pass except TestCalculatorPricesFromTheRowsModelNotABlend, which also fails on clean main on this machine.
  • go test ./context-guru-plugin/ -run 'TestCG|TestInsights|TestTheDashboard': pass, with the host's ANTHROPIC_DEFAULT_*_MODEL variables unset.

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @vz-ibm) Claude Code 2.1.310 offload-review skill, @vz-ibm's session resumed 2 of 2 2 of 2 a3f55251ee85 approve

Verdict: approve

Commit a3f5525 fixes all round-1 findings from both reviewers. The dashboard, the toolfilter doc and both verdict texts now use one test of "never used": SessionsUsed == 0 && Calls == 0. I found no new defect.

Findings

None.

Earlier findings

  • Reviewer 2, finding 1 (tools.js removable lists, row class, "never" pill): fixed. renderUnused (575), removableRows (2314), both cg-row-unused classes (1254, 1376) and all 3 pills (1258, 1383, 1636) now call neverCalled(t). grep finds no other sessions_used test in dash/ui/*.js. The remaining reads only print the number (1260, 1384, 1637) or are the column list (72).
  • Reviewer 2, finding 2 (app.js Overview skills): fixed. Line 1829 uses neverCalled(t) && t.unused_usd > 0.
  • Reviewer 2, finding 3 / reviewer 1, finding 2 (Withheld): fixed. toolsuggest.go:442 now also needs st.Calls == 0. TestWithheldDoesNotCountACalledTool goes through ToolFilterDocFor with the PR's own input, and asserts Withheld == 0.
  • Reviewer 1, finding 1: same as my findings 1 and 2. Fixed, as above.
  • Reviewer 1, finding 3 (verdict "invoked in 0 sessions"): fixed. verdictFor has a new first case, invoked && r.SessionsUsed == 0, that quotes plural(r.Calls, "time"). It sits before the general invoked case, so it wins. The plugin _verdict has the same split. Each has a test that checks the text has "2 call"/"2 times" and does not have "0 session".
  • Non-blocking, dead st.Calls += calls: removed. The comment says the later loop owns Calls. The SessionsUsed++ / continue logic is unchanged.
  • Non-blocking, control test passes with a missing row: fixed with found and t.Fatalf.
  • Non-blocking, allCalls scope and ServerStat.SessionsUsed (reviewer 1): the author did not change them. Both reasons are correct. uses and decls come from the same scope query. Both server facts are true.
  • Non-blocking, no UI test (mine): partly closed. TestTheDashboardUsesOneNeverCalledRule checks the source. The author also reports a live check of main against the branch. I accept that.

Non-blocking

  • dash/uicalls_test.go:25: the regex catches !t.sessions_used, t.sessions_used === 0 and t.sessions_used ?. It does not catch other forms, such as t.sessions_used > 0 or a different variable name (r.sessions_used). That is enough for today's code. A future edit can get past it.
  • neverCalled is a top-level function in app.js, and tools.js calls it. That is correct: both files are classic defer scripts (index.html:1041, 1044), app.js loads first, and tools.js already calls other app.js helpers such as num() the same way.

What I checked

  • Last review: round 1, 5387d77, 2026-10-26T10:17:24Z
  • New commits read: 1 (a3f5525 fix(dash,plugin): use one "never used" rule everywhere, UI included)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 1 round-1 review (10:17:25Z): I read it and checked each finding against the new commit (see "Earlier findings").
    • Author reply (vz-ibm, 10:29:44Z): I checked each claim against the diff. All match. I accept the two "no change" reasons. I did not repeat the live check, because live tests are not approved.
  • Read the full diff 5387d77..a3f5525 (9 files, +135/-20), and the code around each change: buildToolReport, ToolFilterDocFor, verdictFor, _verdict, and the UI functions that changed.
  • Checked every sessions_used / tools_used reader in dash/ui/*.js with grep. insights.js and history.js have none.
  • Checked that the new test helpers exist: stripComments, readUI, mkEvent, day, invWriter{db, seen} (other tests already build it this way), requireTool, scriptsDir.
  • TestWithheldDoesNotCountACalledTool: s2 declares the tool and s1 only calls it, so SessionsUsed == 0 and Calls == 2. The window has 1 session, so suggest returns false. Without the fix, Withheld is 1. The author reports that the test first failed with exactly that.
  • Fail open and reversibility: not touched. This is a read-side report change and UI only. Data dependence: no change.
  • I did not run Go, Python or the UI. Live tests are not approved.

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @vz-ibm) Claude Code 2.1.310 offload-review skill, @vz-ibm's session resumed 1 of 2 2 of 2 a3f55251ee85 approve

Verdict: approve

Commit a3f5525 fixes every blocking finding from both reviewers in round 1. All code that decides "never used" now uses one rule: SessionsUsed == 0 && Calls == 0. This includes the dashboard UI. I found no new defects.

Findings

None.

Status of round-1 findings

  • Reviewer 1, finding 1 / reviewer 2, findings 1 and 2 (the UI lists a called tool or skill as removable): fixed.
    • neverCalled(t) (app.js:61) is !t.sessions_used && !t.calls.
    • All 8 places now use it: renderUnused (tools.js:575), removableRows (tools.js:2314), the Overview skills filter (app.js:1829), the 2 cg-row-unused classes (tools.js:1254, 1376) and the 3 "never" pills (tools.js:1258, 1383, 1636).
    • app.js loads before tools.js (index.html:1041, 1044). Both are classic scripts, so tools.js can call neverCalled as a global.
    • grep sessions_used dash/ui/*.js finds only the helper, the column list (tools.js:72) and 3 num(t.sessions_used) display calls. None of these decides "unused".
  • Reviewer 1, finding 2 / reviewer 2, finding 3 (Withheld counts a called tool): fixed at toolsuggest.go:442.
    • TestWithheldDoesNotCountACalledTool uses the real store path (invWriter.write → ToolFilterDocFor).
    • s1 has Tools = 1, so the r.tools > 0 filter in scopedUses keeps its use row. The tool reaches rep.Tools with Calls = 2 and SessionsUsed = 0. The old code would give Withheld = 1, so the test can fail.
  • Reviewer 1, finding 3 (verdict says "invoked in 0 sessions"): fixed.
    • Go: a new case invoked && r.SessionsUsed == 0 at insightsshape.go:426 comes before case invoked. Its only invoked caller is insightsshape.go:330.
    • Plugin: insights.py:1301-1304 has the same change.
    • Both have tests. The tests check for "2 call" / "2 times" and check that "0 session" is absent.
  • Non-blocking notes:
    • Dead st.Calls += calls (reviewer 1): removed. A comment now says the later loop sets Calls.
    • The control test passed when its row was missing (both reviewers): fixed with found and t.Fatalf.
    • allCalls scope (reviewer 1): the author did not change it. The reason is correct. Both lists come from the same scope query.
    • ServerStat.SessionsUsed (reviewer 1): the author did not change it. The reason is correct. Both facts are true.
    • No UI test (reviewer 2): partly closed by the source-scan test. The author checked the browser live and says so in the reply.

Non-blocking

  • TestTheDashboardUsesOneNeverCalledRule (uicalls_test.go:26) finds only 3 text patterns. A new form such as t.sessions_used == 0 or !rep.x.sessions_used would not be caught. This is acceptable as a guard against regressions.
  • stripComments removes a line only when it starts with a comment. A trailing // ... !t.sessions_used comment on a code line can make the test fail when no code is wrong. It does not occur today.

What I checked

  • Last review: round 1, 5387d77, 2026-10-26T10:17:25Z
  • New commits read: 1. a3f5525, "fix(dash,plugin): use one "never used" rule everywhere, UI included" (9 files, +135/-20).
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files).
  • New items since my last review:
    • Reviewer 2's round-1 review (10:17:24Z). I compared it with mine. Its findings 1-3 are the same as my findings 1-2. I checked each one against the new commit, as listed above.
    • The author's reply comment (10:29:44Z). I checked every claim in it against the diff and the code. The "Live check" and "Checks" sections report runs that I cannot repeat (live tests are not approved). I accept them as the author's report.
  • The full diff 5387d77..a3f5525, with the code around each change: buildToolReport, ToolFilterDocFor, verdictFor and its callers, _verdict and _stale_days, invWriter.write, scopedUses, and the readUI / stripComments / requireTool / scriptsDir test helpers.
  • Every other reader of sessions_used / SessionsUsed in Go, JS and Python. No other code decides "unused" from sessions_used alone.
  • Fail open and data dependence: not touched. This is read-side reporting only, and nothing new is stored.
  • I did not run Go, Python or the UI. Live tests are not approved.

@vz-ibm
vz-ibm merged commit ad87e36 into main Oct 26, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Oct 26, 2026
@OsherElhadad
OsherElhadad deleted the fix/tool-calls-match-last-used branch October 26, 2026 14:31
@vz-ibm vz-ibm mentioned this pull request Oct 26, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants