-
Notifications
You must be signed in to change notification settings - Fork 6.7k
feat(session): add ts_before and breakpoint params to Session.messages API #8996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
feat(session): add ts_before and breakpoint params to Session.messages API #8996
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Potential Related PRs FoundHere are PRs that may be addressing the same or overlapping issues:
Recommendation: Check PR #8535 most carefully, as it addresses the same root issue (#6548) but with a different pagination strategy. Clarify whether the timestamp-based approach in the current PR is preferred, or if both should coexist. |
Analysis of Related PRsI've reviewed all potentially related PRs to clarify how this PR fits into the broader solution space. PR #8535 - "bi-directional cursor-based pagination"Status: Open | Additions: 1,228 lines | Approach: Cursor-based with RFC 5005 Link headers This is the most comprehensive competing approach. Key differences:
Why this PR should still be considered:
PR #6656 - "paginate message loading"Status: Open | Additions: 200 lines An earlier partial implementation that PR #8535 explicitly supersedes. Uses
Verdict: Superseded by #8535. Not relevant to this PR's approach. PR #6138 - "configurable message_limit"Status: Open | Additions: 20 lines | Approach: Config-based limit increase Simply allows users to configure a higher limit (e.g., 500 instead of 100). Why this doesn't solve the problem:
Verdict: Complementary but insufficient. Users with 1000+ message sessions still can't access early history. PR #8627 - "load conversation and session history" (original full implementation)Status: Open (conflicts) | Additions: 176 lines This is the same author's complete implementation that includes:
Relationship to this PR: This PR (#8996) extracts just the server-side foundation from #8627, allowing:
RecommendationThis PR should merge because:
The choice between timestamp-based (#8996) and cursor-based (#8535) pagination isn't either/or - they serve different use cases. Timestamps are ideal for "load everything before X" queries; cursors are ideal for "give me the next/previous page" navigation. |
e086d9d to
e55fcdf
Compare
Adds UI for loading older messages in long-running sessions: - 'Load more messages' banner appears when 100+ messages present - Two loading modes: conversation history (stops at compaction) and full session - Toast notifications show count of messages loaded Depends on: PR anomalyco#8996 (ts_before and breakpoint API params)
Adds UI for loading older messages in long-running sessions: - 'Load more messages' banner appears when 100+ messages present - Two loading modes: conversation history (stops at compaction) and full session - Toast notifications show count of messages loaded Depends on: PR anomalyco#8996 (ts_before and breakpoint API params)
e55fcdf to
85a0f58
Compare
…s API Add optional parameters to Session.messages() for loading older messages: - ts_before: filter to messages created before this timestamp - breakpoint: stop at first compaction summary when true This is a foundational API enhancement that enables clients to implement pagination and history loading without breaking existing functionality.
85a0f58 to
a44b069
Compare
Summary
Adds two optional parameters to
Session.messages()API for loading messages older than the initial 100-message window:ts_before: Unix timestamp - returns messages created before this pointbreakpoint: Boolean - when true, stops at the first compaction summaryProblem
Multiple open issues request the ability to access message history beyond the initial 100-message limit:
Current
Session.messages()only supports alimitparameter, which returns the N most recent messages. There is no way to retrieve older messages.Solution
This PR adds the foundational server-side API enhancement required by all proposed solutions. The implementation is minimal (8 lines of core logic) and non-breaking:
Core changes:
packages/opencode/src/session/index.ts- Add params toSession.messages()schema and iteration logicpackages/opencode/src/server/routes/session.ts- Expose params in HTTP APIWhy this approach:
Usage
Testing
Verified against sessions with 170+ messages and multiple compactions:
ts_beforecorrectly filters to messages older than timestampbreakpoint=truestops at first compaction part