类 ToolExecutionContext
java.lang.Object
io.agentscope.core.tool.ToolExecutionContext
已过时。
Facade for passing custom POJOs to tool methods via priority-based resolution.
Two-layer architecture: External interface + Storage layer (ContextStore).
Priority chain: Call → Agent → Toolkit → Spring (highest to lowest)
Example:
// Register custom POJO
ToolExecutionContext context = ToolExecutionContext.builder()
.register(new UserContext("user123"))
.build();
// Auto-injected by type in tool methods
@Tool
public ToolResultBlock myTool(UserContext ctx) {
return ToolResultBlock.text(ctx.getUserId());
}
- 另请参阅:
-
嵌套类概要
嵌套类 -
方法概要
修饰符和类型方法说明static ToolExecutionContext.Builderbuilder()已过时。Creates a new builder for constructing ToolExecutionContext instances.boolean已过时。Checks whether an object of the specified type exists in any store (regardless of key).boolean已过时。Checks whether an object with the specified key and type exists in any store.static ToolExecutionContextempty()已过时。Creates an empty context.boolean已过时。<T> T已过时。Retrieves an object by type only (for singleton scenarios).<T> T已过时。Retrieves an object by key and type (for multi-instance scenarios).已过时。Gets all stores in priority order.inthashCode()已过时。static ToolExecutionContextmerge(ToolExecutionContext... contexts) 已过时。Merges multiple contexts into priority-based resolution chain.toString()已过时。
-
方法详细资料
-
get
已过时。Retrieves an object by key and type (for multi-instance scenarios).- 类型参数:
T- The object type- 参数:
key- The key identifying the instancetype- The class type to retrieve- 返回:
- The object instance, or null if not found
-
get
已过时。Retrieves an object by type only (for singleton scenarios).- 类型参数:
T- The object type- 参数:
type- The class type to retrieve- 返回:
- The object instance, or null if not found
-
contains
已过时。Checks whether an object with the specified key and type exists in any store.- 参数:
key- The key identifying the instancetype- The class type to check- 返回:
- true if any store contains the object, false otherwise
-
contains
已过时。Checks whether an object of the specified type exists in any store (regardless of key).- 参数:
type- The class type to check- 返回:
- true if any store contains the object, false otherwise
-
getStores
已过时。Gets all stores in priority order.- 返回:
- Unmodifiable list of stores (never null, may be empty)
-
merge
已过时。Merges multiple contexts into priority-based resolution chain.Earlier contexts have higher priority.
- 参数:
contexts- The contexts to merge, in priority order (highest first)- 返回:
- A new merged context
-
builder
已过时。Creates a new builder for constructing ToolExecutionContext instances.- 返回:
- A new builder
-
empty
已过时。Creates an empty context.- 返回:
- An empty ToolExecutionContext
-
equals
已过时。 -
hashCode
public int hashCode()已过时。 -
toString
已过时。
-
RuntimeContextinstead. Register POJOs viaRuntimeContext.builder().put(Type.class, value).build()and pass toagent.call(msg, runtimeContext).