Skip to content

Enhancement: Exact counts without paging rows - #464

Merged
rafaeljusto merged 1 commit into
mainfrom
feature/tool-counts
Aug 17, 2026
Merged

Enhancement: Exact counts without paging rows#464
rafaeljusto merged 1 commit into
mainfrom
feature/tool-counts

Conversation

@rafaeljusto

Copy link
Copy Markdown
Contributor

Description

twapi-go-sdk v1.21.5 exposes meta.page.count on v3 list endpoints. Surface it in two ways: count_only on the 27 list tools whose endpoints report a count, and count_tasks, count_projects, count_milestones, count_timelogs for a model reasoning from "how many" rather than from a list call. Both answer {"count": N} with no rows, and the count tools are derived from their list tool with count_only injected, so the filters stay defined once.

image image image

helpers.NewCountToolResult rewires the request by reflection — page 1, one row, skipCounts=false, no sideloads, fieldsets or cursor — so a list tool needs one branch and a future one needs no count code. Pinning the exact count is correctness, not economy: skipCounts=true keeps count in the response but replaces the total with the lower bound (page * pageSize) + 1, which is 2 at pageSize=1, and the SDK's ResolveCount only clears that for callers decoding the typed response — which the list tools deliberately do not.

The tests assert on the outgoing query, because the mocks reply with the same canned body whether an exact count was asked for or not. Tool definitions grow by 8%.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Testing

  • Tests pass locally (go test -v ./...)
  • Added/updated tests for new functionality

Checklist

  • Code follows project style guidelines
  • Self-reviewed the code
  • Added necessary documentation
  • No new warnings or errors

@rafaeljusto
rafaeljusto requested a review from a team as a code owner August 17, 2026 18:44
twapi-go-sdk v1.21.5 exposes `meta.page.count` on v3 list endpoints. Surface it
two ways: `count_only` on the 27 list tools whose endpoint reports a count, and
`count_tasks`, `count_projects`, `count_milestones`, `count_timelogs` for a model
reasoning from "how many" rather than from a list call. Both answer `{"count": N}`
with no rows, and the count tools are derived from their list tool with
`count_only` injected, so the filters stay defined once.

`helpers.NewCountToolResult` rewires the request by reflection — page 1, one row,
`skipCounts=false`, no sideloads, fieldsets or cursor — so a list tool needs one
branch and a future one needs no count code. Pinning the exact count is
correctness, not economy: `skipCounts=true` keeps `count` in the response but
replaces the total with the lower bound `(page * pageSize) + 1`, which is 2 at
`pageSize=1`, and the SDK's `ResolveCount` only clears that for callers decoding
the typed response — which the list tools deliberately do not.

The tests assert on the outgoing query, because the mocks reply with the same
canned body whether an exact count was asked for or not. Tool definitions grow 8%.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@rafaeljusto
rafaeljusto merged commit 523f6e9 into main Aug 17, 2026
3 checks passed
@rafaeljusto
rafaeljusto deleted the feature/tool-counts branch August 17, 2026 21:55
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.

1 participant