类 RuntimeContext
java.lang.Object
io.agentscope.core.agent.RuntimeContext
Per-call metadata for an agent run: session-scoped fields plus a thread-safe attribute bag and
an optional
ToolExecutionContext (tool-POJO / DI layer).
Attributes are not persisted. Hooks and tools may read and update the same instance for the
duration of a single call.
-
嵌套类概要
嵌套类 -
方法概要
修饰符和类型方法说明Merges this context's data into aToolExecutionContextfor tool invocations.static RuntimeContext.Builderbuilder()static RuntimeContext.Builderbuilder(RuntimeContext source) static RuntimeContextempty()Shallow, mutable empty context (null session fields, empty attribute maps, no tool context).<T> T<T> T<T> TgetExtra()View of string-keyed attributes; mutating the returned map affects this context.Returns the tool execution context provided at build time, if any.<T> void<T> voidvoidstatic AgentStateresolveAgentState(RuntimeContext ctx, Agent fallbackAgent) Resolves the liveAgentStatefor the current call, preferring the call-scoped state carried onctx(concurrency-safe) and falling back tofallbackAgent's state only when the context carries none.voidsetAgentState(AgentState agentState) Installs the call-scopedAgentState.
-
方法详细资料
-
empty
Shallow, mutable empty context (null session fields, empty attribute maps, no tool context). -
getSessionId
-
getUserId
-
getAgentState
Returns the call-scopedAgentStatefor this run, ornullwhen accessed outside of an activecall(). Prefer this overagent.getAgentState()from middlewares and tools so the correct session's state is used under concurrency. -
setAgentState
Installs the call-scopedAgentState. Called by the agent at call entry; not part of the public tool/middleware contract. -
resolveAgentState
Resolves the liveAgentStatefor the current call, preferring the call-scoped state carried onctx(concurrency-safe) and falling back tofallbackAgent's state only when the context carries none. Middlewares and tools should use this instead of callingagent.getAgentState()directly, which is not call-scoped under concurrency.- 参数:
ctx- the per-call runtime context (may benull)fallbackAgent- the agent to fall back to (may benull)- 返回:
- the resolved
AgentState, ornullif neither source provides one
-
getToolExecutionContext
Returns the tool execution context provided at build time, if any.Does not include runtime attribute projections; use
asToolExecutionContext(). -
get
-
put
-
get
-
put
-
get
-
put
-
builder
-
getExtra
View of string-keyed attributes; mutating the returned map affects this context.Typed
get(Class)values are not included; use type-based accessors. -
asToolExecutionContext
Merges this context's data into aToolExecutionContextfor tool invocations.Order: this instance is registered and exposed first (highest priority in
ToolExecutionContext.merge(io.agentscope.core.tool.ToolExecutionContext...), then aContextStorefor typed and string attributes, then stores from the nestedgetToolExecutionContext()(if any). -
builder
-