agentscope-java icon indicating copy to clipboard operation
agentscope-java copied to clipboard

Regression: #2760 dropped permission context when loading legacy v1 session state (re-opens #2768)

Open chang6666 opened this issue 3 months ago • 3 comments

Summary

#2769 fixed #2768 ("ReActAgent legacy-state load silently drops permissionContext (downgrades to DEFAULT)") by forwarding the caller's permCtx to LegacyStateLoader. Commit 605978292 (#2760) rewrote ReActAgent.loadOrCreateAgentStateForSlot(...) and dropped that argument, calling the 3-arg LegacyStateLoader.loadFromLegacySessionWithPresence(stateStore, userId, sessionId) overload again — so the regression described in #2768 is live on main again.

Impact

Same as #2768: any session that still has v1-era keys (memory_messages / toolkit_activeGroups) but no new-format agent_state — typically the first turn after a 1.x → 2.0 migration — gets its caller-configured permission mode (e.g. BYPASS) silently downgraded to DEFAULT.

Repro / Fix

  • Repro: seed v1 legacy keys, build an agent with permissionContext(BYPASS), perform the first call() — the reconstructed state comes back DEFAULT instead of BYPASS.
  • Fix: PR #2886 (passes permCtx to the 4-arg overload; includes an end-to-end regression test ReActAgentLegacyPermissionContextTest that fails on current main with expected: <BYPASS> but was: <DEFAULT>).

chang6666 avatar Aug 28 '26 16:08 chang6666

Issue Evaluation

Category: bug | Area: area/core/agent | Status: Confirmed regression (verified against current main)

Root Cause: ReActAgent.loadOrCreateAgentStateForSlot receives the caller's permCtx and uses it for the fresh-state path, but its legacy-state path calls the 3-arg LegacyStateLoader.loadFromLegacySessionWithPresence(stateStore, userId, sessionId) overload, which forwards null and silently downgrades a caller-configured permission mode (e.g. BYPASS) to DEFAULT. This re-introduces the behaviour already fixed in #2769 for #2768 after #2760 rewrote the method. Impact: Any session that still has v1-era keys (memory_messages / toolkit_activeGroups) but no new-format state loses its permission context on load. Severity: high

The fix is to forward permCtx through the legacy load path (the same shape as #2886). Please ensure a regression test pins the legacy + permission-context combination.


Automated evaluation by github-manager-bot

oss-maintainer avatar Sep 14 '26 15:09 oss-maintainer

The call site this regression lives in is still on 2.0.x (50886798): ReActAgent.loadOrCreateAgentStateForSlot calls the three-argument LegacyStateLoader.loadFromLegacySessionWithPresence(stateStore, userId, sessionId), so a session that only has v1 keys is reconstructed without the builder's permissionContext. main no longer has this call.

I'd like to fix it on 2.0.x, with the same shape as #2886 / #3221 (the permCtx argument forwarded), plus a regression test that pins the legacy + permission-context combination through ReActAgent. LegacyStateLoaderTest covers the loader's four-argument overload, but nothing covers the caller.

As far as I can tell from the code, the effect on 2.0.x is limited to the getAgentState(...) accessors: activateSlotForContext applies the builder's context again on the first activation of a slot, so a call() is not affected. I will confirm that with the test before opening the PR.

aiyili avatar Nov 27 '26 04:11 aiyili

Opened #4452 against 2.0.x.

The test confirmed what I wrote above: with the change, a session that only has v1 keys is reconstructed with the builder's context, mode and rules, where it was DEFAULT with no rules before. Two cases pass before and after and are there to bound the change: an existing state keeps its own context, and a call() applies the builder's context on first activation. So on 2.0.x the regression was visible through getAgentState(...), not through a call.

The full agentscope-core suite has the same result before and after on Windows and in a Linux container.

aiyili avatar Nov 27 '26 05:11 aiyili