improve(sessions): speed up session-key routing - #127249
Merged
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
steipete
marked this pull request as ready for review
August 21, 2026 15:37
Contributor
Author
|
Land-ready proof for exact head
No agent transcript is attached or published. |
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Aug 22, 2026
Amp-Thread-ID: https://ampcode.com/threads/T-01a02481-e149-77dd-a132-a2797e238ef8 Co-authored-by: Amp <amp@ampcode.com>
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.
What Problem This Solves
Resolves repeated CPU and allocation work in session routing: each parse of an already-normalized
agent:<id>:<rest>key tokenized the complete key, allocated a token array and tail array, then rejoined every remaining segment even though routing only needs the first two delimiters.Why This Change Was Made
The canonical parser now validates the exact
agent:prefix, locates the agent boundary once, and slices the two returned fields directly. This keeps the existing normalization owner and malformed-key rejection semantics, including rejecting an empty agent segment or first rest segment. Opaque provider-owned peer IDs and all downstream routing remain unchanged.This is the owner-level fix rather than a caller cache:
parseAgentSessionKeyis the shared parser used by routing, event-session handling, policy derivation, and session-store conversion, so avoiding redundant tokenization there improves every caller without adding lifecycle or freshness state.User Impact
Ordinary session routing and policy decisions use less CPU and allocate fewer temporary strings/arrays. There is no intended output, configuration, storage, protocol, or session-identity change.
Production LOC: +6/-6 (net 0) | Tests: +0/-0
Evidence
3ae7ba319461c00aba59e0d1b74df0ac0e21f45e; head:510d94ddb45d941445bb098d4be26273d946300b.String.prototype.splitcalls changed from 10,000 to 0; checksum stayed417780.resolveAgentIdFromSessionKeymedian: 1375.725 ms → 292.767 ms (4.70×)e1d45dd6b534a6d16d77da1fc05cb7f6db3779668847961a28740cac4e87577f.node scripts/check-changed.mjs: passed.pnpm build: passed; only existing third-party direct-eval warnings appeared.gpt-5.6-sol/high; no findings; patch correct confidence 0.99.No new timing or implementation-coupled test was committed: existing behavior suites already cover the parser contract, while the deterministic external split-count proof captures the performance defect without adding a production seam.
Provenance: the original full-tail split/join shape was introduced in
de3b68740aa9(2026-01-18, Peter Steinberger); strict empty-segment semantics were carried forward by #89884 /65fec9d787e3(2026-06-27, authored by @mushuiyu886 and merged by @steipete). This change preserves those semantics.AI-assisted: yes (Amp). No agent transcript is attached or published.