Skip to content

Feat: surface total result count in query-based tool responses#49

Open
JonathanGodley wants to merge 1 commit into
MadLlama25:mainfrom
JonathanGodley:feat/query-result-counts
Open

Feat: surface total result count in query-based tool responses#49
JonathanGodley wants to merge 1 commit into
MadLlama25:mainfrom
JonathanGodley:feat/query-result-counts

Conversation

@JonathanGodley

Copy link
Copy Markdown
Contributor

Summary

  • Query-based tools now show total result counts (e.g. "Showing 20 of 3376 results.")
  • Added QueryResult<T> interface and getQueryResult() helper in jmap-client
  • All query methods (getEmails, searchEmails, getRecentEmails, advancedSearch) pass calculateTotal: true and return QueryResult with items + total
  • formatQueryResult() helper generates the summary line
  • Search limits capped at 100 for list_emails, search_emails, and advanced_search

This gives AI clients visibility into how many results exist beyond the returned page, which is useful for deciding whether to refine a search or paginate.

Test plan

  • getEmails returns QueryResult with total
  • searchEmails returns QueryResult with total
  • getRecentEmails returns QueryResult with total
  • advancedSearch returns QueryResult with total
  • formatQueryResult generates correct summary lines
  • All existing tests pass

Query-based tools (list_emails, search_emails, get_recent_emails,
advanced_search, list_contacts, search_contacts, list_calendar_events)
now show "Showing X of Y results" when results are truncated, so
callers know more data is available.

Uses JMAP calculateTotal (RFC 8620 §5.5) and a shared QueryResult
type. When total is unavailable, the count is omitted rather than
showing a misleading "X of X".
@MadLlama25

Copy link
Copy Markdown
Owner

Still interested in this one — surfacing "Showing 20 of 3376" is genuinely useful for AI callers deciding whether to paginate or refine. It's the last open PR from your batch, but main has moved a lot since it was cut (v1.9.2 through v1.11.0): the limit caps you added here landed separately, and the search/list surface grew *_metadata variants (#70) plus multi-mailbox filters (#71) that would also want totals. If you're up for rebasing onto current main and extending QueryResult across the new variants, I'd be glad to review and land it in the next feature release. If not, let me know and we'll fold the calculateTotal work in ourselves with credit.

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