fix(core): preserve permission context when loading legacy v1 session state - #2769
Merged
Conversation
… state LegacyStateLoader reconstructs an AgentState from v1 session keys (memory_messages / toolkit_activeGroups) and never set a permissionContext, so a session with legacy keys and no new-format agent_state silently downgraded to the default permission mode even when the caller supplied a non-default context (for example BYPASS). Add overloads accepting a PermissionContextState and pass the in-scope permCtx from ReActAgent.loadOrCreateAgentStateForSlot, matching what freshState already does. Backward compatible: the old overloads keep the default behaviour when no permission context is supplied.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
LGTM. The legacy v1 session loading path now correctly preserves the caller-supplied permission context while keeping the existing overload behavior backward compatible. The tests cover permission propagation, default behavior, and preservation of legacy session data. |
dailingtao
approved these changes
Aug 26, 2026
jujn
approved these changes
Aug 26, 2026
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.
fix(core): preserve permission context when loading legacy v1 session state
Closes #2768
Problem
ReActAgent.loadOrCreateAgentStateForSlot(...)loads a session's state in this order:agent_stateentry from theAgentStateStore,memory_messages/toolkit_activeGroups) viaLegacyStateLoader,freshState(permCtx, ...)).Step 2 is leaky:
LegacyStateLoaderreconstructs theAgentStatewith only the legacyconversation context (+ tool activation groups) and never sets
permissionContext. Legacykeys cannot carry one — the concept did not exist in v1 — so the reconstructed state silently
falls back to the default
DEFAULTpermission mode. This happens even though the callerexplicitly supplied a non-default permission context (for example
BYPASS) that step 3 wouldhave preserved, and even though
permCtxis already in scope at the call site.Affected sessions: any session that still has v1-era keys but no new-format
agent_stateyet —typically the first turn after a 1.x → 2.0 migration. The caller-configured permission mode is
silently downgraded, weakening permission semantics.
Change
LegacyStateLoader.loadFromLegacySession(...)/loadFromLegacySessionWithPresence(...):new overloads accepting a
PermissionContextState; when non-null it is attached to thereconstructed
AgentState. The existing overloads are kept and delegate withnull, sobehaviour for callers without a specific permission context is unchanged.
ReActAgent.loadOrCreateAgentStateForSlot(...): pass the in-scopepermCtxinto the legacyload, exactly like
freshStatealready does.Tests
LegacyStateLoaderTest(5 tests):context;
found=false.Checklist
mvn clean verifyon Linux + Windows)