Skip to main content
The tool system enables agents to perform external operations such as API calls, database queries, file operations, etc.

Core Features

  • Annotation-Based: Quickly define tools using @Tool and @ToolParam
  • Reactive Programming: Native support for Mono/Flux async execution
  • Auto Schema: Automatically generate JSON Schema for LLM understanding
  • Tool Groups: Dynamically activate/deactivate tool collections
  • Preset Parameters: Hide sensitive parameters (e.g., API Keys)
  • Parallel Execution: Support parallel invocation of multiple tools

Quick Start

Define Tools

Note: The name attribute of @ToolParam is required because Java doesn’t preserve parameter names by default.

Strict Mode

strict controls whether model providers that support strict schema enforcement should strictly follow the tool parameter schema.
When strict mode is configured, AgentScope preserves and propagates it consistently through:
  • @Tool(..., strict = true) annotation-based registration
  • AgentTool interface implementations (via getStrict())
  • Toolkit#registerSchema(...) and Toolkit#registerSchemas(...)

Register and Use

Tool Types

Sync Tools

Return results directly, suitable for quick operations:

Async Tools

Return Mono<T> or Flux<T>, suitable for I/O operations:

Streaming Tools

Use ToolEmitter to send intermediate progress, suitable for long-running tasks (progress is only visible to Hooks, not sent to LLM):

Return Types

Tool Groups

Manage tools by scenario with dynamic activation/deactivation:
Use Cases:
  • Permission control: Activate different tools based on user roles
  • Scenario switching: Use different tool sets at different conversation stages
  • Performance optimization: Reduce the number of tools visible to LLM

Preset Parameters

Hide sensitive parameters (e.g., API Key) from LLM:
Effect: LLM only sees to and subject parameters; apiKey is auto-injected.

Tool Execution Context

Pass business objects (e.g., user info) to tools without exposing to LLM:
See Agent documentation for detailed configuration.

Built-in Tools

File Tools

Shell Command Tool

Quick Start:

Multimodal Tools

Sub-agent Tools

Agents can be registered as tools for other agents to call. See Agent as Tool for details.

AgentTool Interface

For fine-grained control, implement the interface directly:

Configuration Options

Meta Tools

Allow agents to autonomously manage tool groups:
When there are many tool groups, agents can autonomously choose which groups to activate based on task requirements.

Tool Suspend

When a tool throws ToolSuspendException, the Agent execution pauses and returns to the caller, allowing external systems to perform the actual execution before resuming. Use Cases:
  • Tool requires external system execution (e.g., remote API, user manual operation)
  • Need to asynchronously wait for external results
Usage:
Resume Execution:

Schema Only Tool

Register only the tool’s schema (name, description, parameters) without execution logic. When LLM calls this tool, the framework automatically triggers suspension and returns to the caller for execution. Use Cases:
  • Tool implemented by external systems (e.g., frontend, other services)
  • Dynamically register third-party tools
Usage:
The call flow is the same as Tool Suspend: LLM calls → returns TOOL_SUSPENDED → external execution → provide result to resume.

Complete Examples