Skip to content

fix(core): pass builder permission context when loading legacy v1 session state - #2886

Open
chang6666 wants to merge 4 commits into
agentscope-ai:mainfrom
chang6666:fix/legacy-session-permission-context
Open

fix(core): pass builder permission context when loading legacy v1 session state#2886
chang6666 wants to merge 4 commits into
agentscope-ai:mainfrom
chang6666:fix/legacy-session-permission-context

Conversation

@chang6666

@chang6666 chang6666 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #2768 / re-lands #2769

Commit 6059782 (#2760) rewrote loadOrCreateAgentStateForSlot and dropped the permCtx argument, calling the 3-arg LegacyStateLoader.loadFromLegacySessionWithPresence overload. Legacy v1 keys (memory_messages / toolkit_activeGroups) never carry a permission context, so the first turn after a 1.x -> 2.0 migration silently downgraded the caller-configured permission mode to DEFAULT, re-introducing the bug fixed by #2769.

Changes

  • loadOrCreateAgentStateForSlot passes the builder-time permission context to the 4-arg LegacyStateLoader overload (original fix(core): preserve permission context when loading legacy v1 session state #2769 re-land).
  • LegacyStateLoader now also preserves the slot identity on the reconstructed state: sessionId and userId were previously left unset, so AgentState auto-generated a random sessionId that got persisted into the migrated agent_state.
  • The 3-arg overloads on LegacyStateLoader (no permission context) are deprecated so future callers cannot silently fall back to DEFAULT again.
  • End-to-end regression test (ReActAgentLegacyPermissionContextTest) covering: builder BYPASS surviving legacy load, migrated session id stability, and an existing v2 state staying authoritative over the builder template.

Verification

  • mvn -pl agentscope-core test -Dtest=ReActAgentLegacyPermissionContextTest,LegacyStateLoaderTest (JDK 17): 8/8 pass
  • spotless:check and git diff --check clean

…sion state

Commit 6059782 (agentscope-ai#2760) rewrote loadOrCreateAgentStateForSlot and
dropped the permCtx argument, calling the 3-arg
LegacyStateLoader.loadFromLegacySessionWithPresence overload. Legacy v1
keys (memory_messages / toolkit_activeGroups) never carry a permission
context, so the first turn after a 1.x -> 2.0 migration silently
downgraded the caller-configured permission mode to DEFAULT,
re-introducing the bug fixed by agentscope-ai#2769.

Pass the builder-time permission context to the 4-arg overload and add
an end-to-end regression test (ReActAgentLegacyPermissionContextTest)
that fails without the fix: expected BYPASS but was DEFAULT.

Re-lands agentscope-ai#2769 (fixes agentscope-ai#2768).
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@guslegend0510 guslegend0510 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.

LGTM

@chang6666 chang6666 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@chang6666 chang6666 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

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.

ReActAgent legacy-state load silently drops permissionContext (downgrades to DEFAULT)

2 participants