Repository navigation
Description
Environment
- AgentScope Java source commit:
e3a412ed2cc944e401da861c8d5e464b967724e9 - Two independent
HarnessAgent/ReActAgentinstances - Two independent Jedis clients sharing one official
RedisDistributedStore - Same
(userId, sessionId) - Different JVM/runtime replica identity
Reproduction
- Build two Harness runtimes backed by the same Redis distributed store and session.
- Use a model barrier so both calls enter model execution after both agents have loaded the same initial AgentState.
- Submit a distinct user turn through each runtime concurrently.
- Release both model calls and wait for both agent calls to complete successfully.
- Reload
agent_statefrom Redis.
Actual
Both calls return successfully, but persisted AgentState contains only one of the two turns. The other turn is lost.
The current same-session guards are process-local:
AgentBase.callGatesserializes by slot only inside one agent instance/JVM.- Harness
SessionTurnGateuses an in-memoryConcurrentHashMap<String, Semaphore>. AgentStateStore.save(...)is unconditional full replacement.RedisAgentStateStore.save(...)performs a plain set without version/CAS/fencing.
Reloading AgentState at the start of each call helps replica drift between sequential calls, but cannot prevent two replicas from concurrently loading the same version and overwriting each other.
Expected
AgentScope should expose an official distributed same-session serialization contract, for example:
- a lease/claim with TTL, owner token and fencing token around the complete agent turn; or
- versioned AgentState load/save with bounded conflict handling that is safe for side-effecting tools; or
- an official distributed session router/guard abstraction backed by Redis/JDBC.
Required behavior:
- same
(userId, sessionId)across replicas cannot execute conflicting turns concurrently; - lease expiry/crash recovery does not allow a stale worker to commit after takeover;
- cancellation and HITL suspension release or transfer ownership deterministically;
- different sessions remain parallel;
- state, tool execution and emitted terminal events agree on one winning fenced turn;
- fresh-node continuation is supported without product-host locks.
Why upstream
Agent execution serialization, AgentState persistence and HITL/tool side effects are Core/Harness runtime facts. Product hosts should not build a second Redis lock, queue or session coordinator around AgentScope.
A regression test can use two independent Redis clients and two Harness runtimes with a model barrier, then assert both turns are retained or one is explicitly rejected before model/tool execution.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsBacklog
Activity
richuV commentedon Jul 12, 2026
Implementation audit update: reusing SandboxExecutionGuard is not sufficient for agent turns. Its contract explicitly permits a second holder after TTL expiry and has no fencing token, so a paused/stale worker could still execute tools and overwrite AgentState after takeover.
Proposed upstream contract:
I am keeping the existing real two-runtime Redis barrier canary as the behavior proof and will not add a JCode Redis lock/queue. A partial TTL-only lock would not satisfy crash recovery or side-effect safety.
oss-maintainer commentedon Jul 14, 2026