Skip to content

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

Closed

Description

@Letter2025

Issue draft — A3: LegacyStateLoader drops permission context (silent downgrade)


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

Body:

Problem

ReActAgent.loadOrCreateAgentStateForSlot(...) loads a session's state in this order:

  1. a new-format agent_state entry from the AgentStateStore,
  2. else v1 legacy session keys (memory_messages / toolkit_activeGroups) via
    LegacyStateLoader,
  3. else a fresh state built from the caller's parameters.

Step 2 is leaky: LegacyStateLoader.loadFromLegacySessionWithPresence(...) reconstructs the
AgentState with only context(msgs) (+ tool context), and never sets permissionContext.
Legacy keys carry no permission context (the concept did not exist in v1), so the reconstructed
state falls back to the default DEFAULT mode — even when the caller explicitly supplied a
non-default permission context (for example BYPASS) that freshState(permCtx, ...) (step 3)
would have preserved, and even though permCtx is already in scope at the call site.

Concrete trace (on main):

// ReActAgent.loadOrCreateAgentStateForSlot
AgentState fresh = freshState(permCtx, agentId, userId, sessionId, initialActiveToolGroups); // has permCtx
...
LegacyStateLoader.LegacyLoadResult legacy =
        LegacyStateLoader.loadFromLegacySessionWithPresence(stateStore, userId, sessionId); // permCtx NOT passed
if (legacy.found()) {
    return new VersionedState<>(legacy.state(), version); // permission mode silently DEFAULT
}
// LegacyStateLoader.loadFromLegacySessionWithPresence
AgentState.Builder builder = AgentState.builder().context(msgs); // no .permissionContext(...)

Impact: any session that has v1-era keys but no new-format agent_state yet (typical for the
first post-upgrade turn) silently loses its caller-configured permission mode. This can weaken
permission semantics (e.g. a pre-seeded BYPASS session degrading to DEFAULT).

Proposed fix

  • LegacyStateLoader.loadFromLegacySession(...) / ...WithPresence(...): add overloads accepting
    a PermissionContextState; attach it to the reconstructed AgentState when non-null (old
    overloads kept for backward compatibility).
  • ReActAgent.loadOrCreateAgentStateForSlot(...): pass the in-scope permCtx into the legacy
    load, exactly like freshState already does.

Behavior for callers without a specific permission context is unchanged.

Environment

  • agentscope-java main (2.0.3-SNAPSHOT); reproduced against 2.0.1 sources too (same path)

Activity

  1. added
    bug
    area/core/agent
    on Aug 19, 2026
  2. moved this from In progress to Done in AgentScope Javaon Aug 26, 2026
  3. added a commit that references this issue on Aug 26, 2026
    e697475
  4. moved this from Done to In progress in AgentScope Javaon Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/core/agentbug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions