Skip to content

fix(adk): keep full session state when num_recent_events is set#2329

Open
mesutoezdil wants to merge 2 commits into
kagent-dev:mainfrom
mesutoezdil:fix/session-state-num-recent-events
Open

fix(adk): keep full session state when num_recent_events is set#2329
mesutoezdil wants to merge 2 commits into
kagent-dev:mainfrom
mesutoezdil:fix/session-state-num-recent-events

Conversation

@mesutoezdil

Copy link
Copy Markdown
Contributor

get_session only fetched the last N events when num_recent_events was set, then built session.state by replaying just those N events. Any state_delta set by an older event outside that window never made it into state, silently, no error.

Now the full event history is always fetched to build state, and num_recent_events only trims the events list on the returned session, after state is already correct.

Added a test with a mock server that respects the limit query param, confirmed it fails against the old code and passes with the fix.

get_session only fetched the last N events when num_recent_events was
set, then built session.state by replaying just those N events. Any
state_delta set by an older event outside that window never made it
into state, silently.

Now the full event history is always fetched to build state, and
num_recent_events only trims the events list returned on the session,
after state is already correct.

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
@mesutoezdil
mesutoezdil requested a review from a team as a code owner July 25, 2026 10:22
@github-actions github-actions Bot added the bug Something isn't working label Jul 25, 2026
…-recent-events

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant