Class AgentStateRestorer
java.lang.Object
io.agentscope.spring.boot.admin.snapshot.AgentStateRestorer
Copies the mutable fields of a snapshotted
AgentState back into a live one.
Why a copy instead of a swap: ReActAgent holds its AgentState in a
private final field, so we cannot replace the instance from outside. The next best
thing is a field-by-field overwrite of everything that has a setter or is itself mutable.
Coverage:
summary— overwritten via setterreplyId— overwritten via settercurIter— overwritten via settershutdownInterrupted— overwritten via settercontext— cleared and refilled in-place
The sub-context records (permissionContext, toolContext,
tasksContext, planModeContext) are not restored — they would need
additional core support to be swappable mid-run. Currently this matches the scope of
session:compact (which only mutates summary + context); broader undo
coverage tracks the AgentState refactor in project_java-agentstate-refactor.md.
-
Method Summary
-
Method Details
-
restore
Restore the liveAgentStatefrom a snapshot.- Parameters:
live- the agent's current state (mutated in place)snapshotJson- JSON produced byAgentState.toJson()- Throws:
IllegalArgumentException- if the JSON is invalid or targets a different session
-