Repository navigation
fix(core): pass the builder permission context to the legacy state loader on 2.0.x (#2888) - #4452
Merged
juruoO-o merged 2 commits intoDec 1, 2026
Conversation
…ader on 2.0.x (agentscope-ai#2888) `ReActAgent.loadOrCreateAgentStateForSlot` reconstructed a session that only has v1 keys through the three-argument `LegacyStateLoader.loadFromLegacySessionWithPresence`, which passes no permission context. Legacy keys carry none, so the state got the default context although the builder had configured one, while the fresh-state branch of the same method used the builder's. On `2.0.x` this shows through `getAgentState(...)`, which returns the state as loaded; a `call()` applies the builder's context again on first activation. Forwards `permCtx` to the four-argument overload, the shape of agentscope-ai#2886 and agentscope-ai#3221. An existing state is still loaded as it was persisted. Test: `ReActAgentLegacyPermissionContextTest` covers the legacy path with and without a builder context, an existing state, and the first activation of a call.
This was referenced Nov 27, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Fixes #2888 on
2.0.x, where the call still exists.mainno longer has it.Problem
A session that only has v1 keys (
memory_messages/toolkit_activeGroups) is reconstructed byLegacyStateLoaderon first load. Legacy keys carry no permission context, andReActAgent.loadOrCreateAgentStateForSlotcalls the three-argument overload, which passesnull. The reconstructed state therefore gets the default context although the builder configured one, mode and rules alike. The fresh-state branch of the same method does use the builder's context.On
2.0.xthis shows throughgetAgentState(userId, sessionId)andgetAgentState(ctx), which return the state as loaded. Acall()is not affected:activateSlotForContextapplies the builder's context the first time it activates a slot.Fix
permCtxis forwarded to the four-argument overload, the shape of #2886 and #3221. Nothing else changes: a state that already exists is still loaded as it was persisted.Tests
ReActAgentLegacyPermissionContextTest(new, 4 cases).LegacyStateLoaderTestalready covers the loader's four-argument overload; nothing covered the caller.2.0.xexpected ... mode=BYPASS, denyRules={shell=[...]}but wasmode=DEFAULTwith no rulescall()applies the builder's context on first activationThe last two pass before and after on purpose: they bound the change. A variant of the fix that also overwrites the context of an existing state fails the third case (
expected: <EXPLORE> but was: <BYPASS>).Verification
The full
agentscope-coresuite was run before and after the change on Windows and in a Linux container. The failing lists are identical; the only difference is the 4 added tests.DangerousPathBypassTest.symlink*(no symlink privilege),SkillBoxTest$UploadContainment.preservesLegacyNamesWithRelativeNonNormalizedWorkDirectorymaven:3.9-eclipse-temurin-17)CI. The first run of this PR was red for reasons that lay in the base branch: since the backports of 2026-11-13, every PR against
2.0.xfailed the Windows job, at first inagentscope-core, and had its Ubuntu job cancelled. Those causes are fixed by #4454 and #4461, merged into2.0.xon 2026-11-27; the harness part went in with #4461. The current run of this PR, on top of them, is green on both systems. The local before/after runs recorded above were made before the fixes existed, which is why the "before" column lists failures that the branch no longer has.