Trim tool call payloads for paginated session loads - #2923
Merged
1 commit merged intoMay 25, 2026
Merged
1 commit merged into
1 commit merged into
Conversation
48a2e79
Collaborator
This was referenced May 25, 2026
Sanjays2402
pushed a commit
to Sanjays2402/hermes-webui
that referenced
this pull request
May 25, 2026
# Conflicts: # CHANGELOG.md
SysAdminDoc
pushed a commit
to SysAdminDoc/hermes-webui
that referenced
this pull request
Jun 26, 2026
# Conflicts: # CHANGELOG.md
bernyforce
pushed a commit
to bernyforce/hermes-webui
that referenced
this pull request
Jul 29, 2026
# Conflicts: # CHANGELOG.md
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.
Thinking Path
/api/session?messages=1&msg_limit=Nis the fast path used when switching sessions. It already sends only a message window, but legacy sessions can still include the full session-leveltool_callslist. For long tool-heavy conversations, that means a small message response can still carry a large amount of historical tool-call data the browser cannot render in the current window.The response contract already exposes
_messages_offset, so the server can use the same message coordinate space to keep only tool calls whoseassistant_msg_idxlands inside the returned window. Full transcript loads keep the existing behavior.What Changed
tool_callsto the returned message window when/api/sessionis loaded with pagination.tool_callsbehavior for non-paginated full transcript loads.tool_callswhen returned messages already include per-message tool metadata.msg_beforepagination.Why It Matters
This keeps session switching payloads proportional to the visible message window. It reduces JSON serialization, transfer size, browser parse work, and render bookkeeping for long sessions with many tool calls, without changing the persisted session format.
A local synthetic benchmark with 2,000 messages, 1,000 legacy session-level tool calls, 1 KiB snippets, and
msg_limit=10reduced the/api/sessionJSON payload from 1,111,267 bytes to 6,487 bytes. Handler + JSON serialization median time dropped from 8.599 ms to 2.436 ms across 150 runs.Verification
/tmp/hermes-webui-pr-venv/bin/python -m py_compile api/routes.py/tmp/hermes-webui-pr-venv/bin/python -m pytest tests/test_session_tail_payload.py -q --timeout=60/tmp/hermes-webui-pr-venv/bin/python -m pytest tests/test_parallel_session_switch.py -q --timeout=60/tmp/hermes-webui-pr-venv/bin/python -m pytest tests/test_webui_state_db_reconciliation.py -q --timeout=60GIT_CONFIG_GLOBAL=/tmp/hermes-webui-test-gitconfig /tmp/hermes-webui-pr-venv/bin/python -m pytest tests/ -v --timeout=60Full-suite result:
6430 passed, 76 skipped, 3 xpassed, 8 subtests passed in 172.26s.Risks / Follow-ups
Session-level tool calls without
assistant_msg_idxare omitted from paginated responses because they cannot be placed into a truncated message window. Full transcript loads still return them.This does not make the frontend initial message limit configurable; that can stay separate.
Model Used
OpenAI GPT-5.5 via Codex, with local shell-based repository inspection and test execution.