feat(activity): add before_ts paging knob to /activity route - #2476
Merged
Merged
Conversation
The wheel-side chat_history MCP tool advertises a `before_ts` parameter for backward paging through long histories, and the docs describe it as the canonical pagination knob — but the server silently ignored it until now. Without this fix, an agent passing before_ts to chat_history would always get the most-recent N rows and pagination would be broken end-to-end. Add `before_ts` query param parsed as RFC3339 at the trust boundary and translated into a `created_at < $X` clause on the existing builder. Mirrors the strict-inequality shape since_id uses for forward paging (`created_at > cursorTime`) so paging across both directions has consistent semantics. Tests: 3 new branches (positive filter, composition with peer_id into the canonical chat_history paging shape, RFC3339 rejection across 4 malformed inputs including URL-encoded SQL injection). Mutation-verified pre-commit; existing 9 activity tests still pass. Reported by self-review on PR #2474. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
HongmingWang-Rabbit
requested a review
from hongmingwang-moleculeai
as a code owner
May 2, 2026 01:04
HongmingWang-Rabbit
pushed a commit
that referenced
this pull request
May 2, 2026
Self-review on PR #2474 + #2476: the comment said we don't forward before_ts, but the code below does. Misleading after #2476 added the server-side filter. Replace with a one-liner that just states the forward-and-validate contract. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Self-review caught after #2472 merged: the wheel-side
chat_historyMCP tool (#2474) advertises abefore_tsparameter for backward paging through long histories, and the docs (#111) describe it as the canonical pagination knob — but the server silently ignored it. Without this fix, an agent passingbefore_tswould always get the most-recent N rows and pagination is broken end-to-end.Fix
Add
before_tsquery param parsed as RFC3339 at the trust boundary and translated into acreated_at < \$Xclause on the existing builder. Mirrors the strict-inequality shapesince_iduses for forward paging (created_at > cursorTime) so paging across both directions has consistent semantics.Test plan
activity_test.go:before_tsfilter binds the parsed time correctlypeer_idinto the canonical chat_history paging shape (arg order pinned)TestActivityList_*tests still passchat_history(peer_id=X, before_ts=Y)actually pages backwardRelated
peer_idfilter (merged; this PR fills the missing pagination piece)chat_historyMCP tool (the wheel-side caller — unblocked by this)🤖 Generated with Claude Code