Skip to content

fix(core): read pending interactions in a single scan - #3582

Open
yflcwl wants to merge 1 commit into
agentscope-ai:mainfrom
yflcwl:fix/pending-single-scan
Open

yflcwl wants to merge 1 commit into
agentscope-ai:mainfrom
yflcwl:fix/pending-single-scan

Conversation

@yflcwl

@yflcwl yflcwl commented Oct 15, 2026

Copy link
Copy Markdown

Problem

SessionInteractions.pending() reads the log in batches of 256 via readAfter().
Each readAfter() call walks the commit chain backward from the head to locate
segments, so the lookup cost repeats per batch. On a ~24k-event session this
produced 67,429 storage reads versus 2,759 for one single scan.
AgentSession.resume() calls pending() on every request, which made resume take
about two minutes on long sessions.

Fix

Read the committed prefix once with a single log.scan(0, head.seq()).
Behavior is unchanged: the same requested/resolved events are applied in the
same order.

Verification

  • Session tests pass: SessionInboxCrashRecoveryTest, JournalSessionLogTest,
    SessionExecutionIdentityTest (15 tests).
  • spotless:check passes.
  • Real-world check on a ~24k-event session: resume validation dropped from
    ~2 minutes to a few seconds.

Copilot AI balanced review requested due to automatic review settings October 15, 2026 08:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@CLAassistant

CLAassistant commented Oct 15, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 不重要不紧急

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants