Skip to content

fix(hub): report pre-limit match count as invocations total - #80

Merged
DominikPinsel merged 1 commit into
mainfrom
fix/hub-invocations-total
Aug 10, 2026
Merged

fix(hub): report pre-limit match count as invocations total#80
DominikPinsel merged 1 commit into
mainfrom
fix/hub-invocations-total

Conversation

@DominikPinsel

Copy link
Copy Markdown
Owner

Closes #76

Problem

The hub computed total after applying limit (list := s.invocations.List(opts); total := len(list)), so:

  • list_invocations (no limit) → total: 19
  • list_invocations with limit=2total: 2, truncated: false

The MCP helper annotateListWithTotal computes truncated = total > returned — correct given a truthful total. Agents relying on truncated/total to decide whether to paginate silently missed data.

Changes (hub)

  • invocations.Store.ListWithTotal(opts) — returns items capped by Limit plus the number of matches before the limit is applied. List now delegates to it.
  • listInvocations handler — reports the pre-limit match count as total; totalPages is derived from the capped list so page links remain valid.

No MCP change needed: annotateListWithTotal now yields truncated: true whenever total > len(invocations).

Acceptance criteria

  • list_invocations?limit=N returns total = number of matching invocations (not min(N, matches))
  • truncated: true whenever total > len(invocations)

Tests

  • New TestStore_ListWithTotalReportsPreLimitCount (with/without limit, filters applied before limit)
  • Updated TestInvocations_ListFilterByLimit (previously asserted the buggy total=2; now asserts total=3 with 2 returned)

go build, go test ./internal/invocations/ ./internal/api/, golangci-lint run all pass.

The invocations list handler computed total after applying opts.Limit
(total := len(list)), so a request with limit=2 against 19 matching
invocations reported total: 2 — and downstream consumers like the MCP
list_invocations tool derived truncated: false from it, silently hiding
that 17 items were cut.

- add Store.ListWithTotal returning items capped by Limit plus the
  number of matches before the limit is applied
- handler now reports the pre-limit match count as total; totalPages
  is derived from the capped list so page links stay valid

Closes #76
@DominikPinsel
DominikPinsel merged commit b117511 into main Aug 10, 2026
3 checks passed
@DominikPinsel
DominikPinsel deleted the fix/hub-invocations-total branch August 10, 2026 21:51
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.

MCP: list_invocations total reflects post-limit list, so truncated annotation is wrong

1 participant