Skip to content

feat(acp): paginate replayed messages in load_session - #10365

Closed
SarthakB11 wants to merge 3 commits into
aaif-goose:mainfrom
SarthakB11:feat/acp-load-session-pagination
Closed

SarthakB11 wants to merge 3 commits into
aaif-goose:mainfrom
SarthakB11:feat/acp-load-session-pagination

Conversation

@SarthakB11

@SarthakB11 SarthakB11 commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Adds optional messageLimit and messageOffset fields on the load_session request meta so clients can replay session history in chunks instead of receiving every message inline (#9358). Both count back from the most recent message; when neither is set the replay is byte-for-byte unchanged. The slicing runs through a small paginate_messages helper that clamps oversized values.

This is the ACP re-do of #9473, which targeted the old goose-server REST GET /sessions/{id} endpoint that was removed in #10224.

Tested: cargo test -p goose acp::server::load_session (8 pass), cargo clippy -p goose --lib -- -D warnings, cargo fmt.

Fixes #9358

Read optional messageLimit/messageOffset from the load_session request
meta and slice the replayed conversation counting back from the most
recent message, mirroring the pagination proposed for the removed REST
GET /sessions/{id} endpoint. When neither is set the replay is
unchanged, so this stays backwards-compatible.

Refs aaif-goose#9358

Signed-off-by: SarthakB11 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3dd7bfa911

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

.map(|c| c.messages().to_vec())
.unwrap_or_default();
let messages = if limit.is_some() || offset.is_some() {
paginate_messages(&messages, limit, offset)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Filter hidden messages before paginating replay

When messageLimit or messageOffset is set, this slices the raw conversation before the replay loop skips !message.metadata.user_visible messages below. In compacted sessions the raw history includes agent-only summary/continuation messages, so a page can be spent partly or entirely on hidden entries; for example, if the newest two raw messages are agent-only, load_session with { "messageLimit": 2 } replays no visible history even though older visible messages exist. Paginate the user-visible replay set instead of the unfiltered session messages.

Useful? React with 👍 / 👎.

Pagination sliced the raw conversation before the replay loop filtered
out hidden agent-only messages, so in compacted sessions a page could be
spent partly or entirely on summary/continuation entries. A request with
messageLimit=2 could replay no visible history even when older visible
messages existed. Filter to the user-visible set first, then paginate, so
messageLimit always yields that many visible messages when they exist.

Signed-off-by: SarthakB11 <[email protected]>
@SarthakB11

Copy link
Copy Markdown
Contributor Author

Good catch. Now filtering to the user-visible set before paginating, so hidden agent-only messages no longer consume the page budget. Added tests.

…-pagination

# Conflicts:
#	crates/goose/src/acp/server/load_session.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd0075ed5b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.map(messages_for_acp_replay)
.unwrap_or_default();
let messages = if limit.is_some() || offset.is_some() {
paginate_messages(&messages, limit, offset)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep tool requests and responses in the same replay page

When a page boundary falls between a ToolRequest and its following ToolResponse—for example, messageLimit: 1 selects a final tool-response message—this slices the pair independently, so replay sends a ToolCallUpdate without the preceding ToolCall. The desktop adapter creates a response-only user message for that update (ui/desktop/src/acp/adapter/tools.ts), which ProgressiveMessageList deliberately suppresses, while the inverse page renders the request as permanently pending. Paginate logical tool-call pairs together, or otherwise ensure each replayed response has its request.

Useful? React with 👍 / 👎.

DOsinga commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the work on paginating ACP session replay. The linked issue targeted the former GET /sessions/{session_id} REST endpoint, which was removed with goose-server; ACP load_session has different replay semantics that need their own design and verification. Since this PR does not implement the closed issue’s request, I’m closing it. We appreciate the contribution.

@DOsinga DOsinga closed this Aug 10, 2026
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.

Pagination for messages in GET /sessions/{session_id}

4 participants