类 AgentState

java.lang.Object
io.agentscope.core.state.AgentState
所有已实现的接口:
State

public final class AgentState extends Object implements State
Mutable per-agent runtime state.

Carries everything a single agent needs to resume mid-conversation: the conversation buffer, a rolling summary, the per-iteration reply identifier, the permission/tool/task sub-contexts, and a counter for the current reasoning iteration.

The context list is exposed as a defensive copy via getContext() and as a live, mutable handle via contextMutable(), mirroring the pattern used by TaskContextState. Storage layers may swap whole AgentState instances or mutate the inner collections in place.

summary is modelled as a free-form String; richer structured forms are left for future iterations once context-compression strategies require them.

  • 方法详细资料

    • getSessionId

      public String getSessionId()
    • getUserId

      public String getUserId()
      Nullable; null = anonymous / single-tenant context.
    • getSummary

      public String getSummary()
    • setSummary

      public void setSummary(String summary)
    • getContext

      public List<Msg> getContext()
      Defensive copy of the conversation buffer.
    • contextMutable

      public List<Msg> contextMutable()
      Live, mutable handle for components that append/replace messages in place.
    • getReplyId

      public String getReplyId()
    • setReplyId

      public void setReplyId(String replyId)
    • getCurIter

      public int getCurIter()
    • setCurIter

      public void setCurIter(int curIter)
    • isShutdownInterrupted

      public boolean isShutdownInterrupted()
    • setShutdownInterrupted

      public void setShutdownInterrupted(boolean shutdownInterrupted)
    • getPermissionContext

      public PermissionContextState getPermissionContext()
    • setPermissionContext

      public void setPermissionContext(PermissionContextState permissionContext)
      Replaces the permission context for this session. Used to change the evaluation mode at runtime (e.g. switching into PermissionMode.BYPASS). Callers that cache a PermissionEngine per session must rebuild it after this call.
      参数:
      permissionContext - the new (non-null) permission context
    • getToolContext

      public ToolContextState getToolContext()
    • getTasksContext

      public TaskContextState getTasksContext()
    • getPlanModeContext

      public PlanModeContextState getPlanModeContext()
    • interruptControl

      public InterruptControl interruptControl()
      The per-session interrupt signal for this state, created on first access. Runtime-only and not serialized.
    • builder

      public static AgentState.Builder builder()
    • toJson

      public String toJson()
      Serialize this state to a pretty-printed JSON string.

      Intended for external storage stores to persist the entire agent state as a single JSON document (e.g., agent_state.json).

    • fromJsonString

      public static AgentState fromJsonString(String json)
      Deserialize an AgentState from a JSON string produced by toJson().
    • equals

      public boolean equals(Object o)
      覆盖:
      equals 在类中 Object
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object