Skip to content

Add runtime branch isolation to SessionMemoryAdvisor - #33

Open
AdepuSriCharan wants to merge 4 commits into
spring-ai-community:mainfrom
AdepuSriCharan:feature/branch-session-isolation
Open

Add runtime branch isolation to SessionMemoryAdvisor#33
AdepuSriCharan wants to merge 4 commits into
spring-ai-community:mainfrom
AdepuSriCharan:feature/branch-session-isolation

Conversation

@AdepuSriCharan

Copy link
Copy Markdown
Contributor

Fixes #15

SessionMemoryAdvisor only supported branch targeting at bean creation via the builder, making per-request branch isolation impossible for multi-agent/multi-tenant use cases.

This PR resolves the EventFilter dynamically per request via EVENT_FILTER_CONTEXT_KEY, falling back to the advisor's configured default when no override is given.

Changes:

  • getEventFilter(context) merges advisor default + request override.
  • before()/after() write user/assistant messages to the resolved branch (via SessionEvent) instead of always writing to root.
  • Added 4 integration tests: runtime override, branch writes, read/write symmetry, default fallback.

Note: Compaction (TurnCountTrigger, SessionService.compact()) is untouched here — will be tracked separately if confirmed branch-unaware.

…moryAdvisor

- Allow the event filter to be overridden per request.
- Load and store conversation history using the resolved branch.
- Preserve the configured filter as the default when no override is provided.
- Add integration tests for runtime branch isolation and fallback behavior.

Signed-off-by: Adepu Sri Charan <sricharan.adepu36@gmail.com>
@tzolov

tzolov commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@AdepuSriCharan can you please limit the changes to the actual fix only and revert the unrelated changes.

Resolves conflicts by integrating upstream's new ID generation feature
with branch isolation logic. Both SessionEvent.id and SessionEvent.branch
are now set correctly on all persisted events.
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.

Add branch-based session isolation to the existing SessionMemoryAdvisor setup

2 participants