Skip to main content

Overview

Agent is the core abstraction of the AgentScope framework, representing an intelligent entity with autonomous decision-making capabilities. It organically integrates the reasoning capabilities of Large Language Models (LLMs), memory systems, tool invocation, and other functions, enabling developers to build AI applications with perception, thinking, and action capabilities. A complete Agent consists of the following core components:
  • Model: Provides language understanding and generation capabilities, serving as the Agent’s “brain”
  • Memory: Stores conversation history and contextual information, giving the Agent “memory”
  • Toolkit: Empowers the Agent to perform external operations such as API calls, database queries, etc.
  • System Prompt: Defines the Agent’s identity, role, and behavioral norms
  • Hook: Provides event-driven extension mechanisms for monitoring and customizing Agent behavior

Agent Types

Reasoning + Acting, a general-purpose Agent combining reasoning and tool execution.
Use Cases:
  • Complex tasks requiring tool invocation
  • Multi-turn conversation applications
  • Problem solving requiring reasoning capabilities

UserAgent

An Agent that receives external input (e.g., command line, Web UI).
Use Cases:
  • Command-line interaction applications
  • Web UI integration
  • Human-AI collaboration scenarios

Core Configuration Options

1. Basic Configuration

name (Required)

The unique identifier name of the Agent.
Purpose:
  • Message sender identification
  • Agent recognition in logging and debugging
  • Differentiation when multiple Agents collaborate

sysPrompt

System prompt defining the Agent’s identity, responsibilities, and behavioral norms.

2. Model Configuration

model (Required)

The LLM model instance that determines the Agent’s language understanding and generation capabilities.

3. Memory Configuration

Stores conversation history, giving the Agent contextual memory.

4. Tool Configuration

toolkit (Optional)

Provides the set of tools the Agent can invoke.
Tool Group Management:
Purpose:
  • Empower Agent to perform external operations
  • Control permissions through tool groups
  • Support dynamic tool activation/deactivation

5. Execution Parameters

maxIters

Maximum number of Agent iterations (reasoning + tool execution loop).
Execution Flow:
Each completion of “reasoning + tool execution” counts as one iteration.

checkRunning

Controls whether to check if the Agent is already running before accepting a new call.
Default Value: true Behavior:
  • When true (default): If call() is invoked while the Agent is still processing a previous request, an IllegalStateException is thrown with the message “Agent is still running, please wait for it to finish”
  • When false: Allows concurrent call() invocations without checking the running state
Use Cases:
  • checkRunning=true (default): Suitable for most scenarios, prevents state corruption from concurrent execution
  • checkRunning=false:
    • Stateless Agents that don’t maintain conversation state
    • Scenarios requiring concurrent request processing
    • Performance testing or load testing
Example:
Notes:
  • When checkRunning=false, ensure the Agent implementation is thread-safe or stateless
  • Memory and context state may become inconsistent with concurrent calls
  • Consider using separate Agent instances for true concurrent processing

modelExecutionConfig

Execution configuration for model calls, controlling timeout and retry behavior.
Implementation Logic: In the ReActAgent’s reasoning phase (ReasoningPipeline), this configuration is injected into GenerateOptions:
Default Configuration (ExecutionConfig.MODEL_DEFAULTS):
  • Timeout: 5 minutes
  • Max attempts: 3 (initial + 2 retries)
  • Initial backoff: 2 seconds
  • Max backoff: 30 seconds
  • Backoff multiplier: 2.0 (exponential)
  • Retry condition: retryable errors (429, 5xx, timeout, network IO errors)
Use Cases:
  • Adjust model API timeout
  • Configure retry strategy (unstable network scenarios)
  • Retry for specific errors
  • Control backoff strategy

toolExecutionConfig

Execution configuration for tool calls, controlling tool execution timeout and retry behavior.
Implementation Logic: In the ReActAgent’s execution phase (ActingPipeline), this configuration is passed when calling toolkit.callTools():
Default Configuration (ExecutionConfig.TOOL_DEFAULTS):
  • Timeout: 5 minutes
  • Max attempts: 1 (no retry)
Notes:
  • Tool calls are generally not recommended for retry due to potential side effects (e.g., database writes, sending emails)
  • If retry is needed, ensure tools are idempotent
  • Increase timeout for long-running tools
Configuration Merging: ExecutionConfig supports parameter-level configuration merging:

6. Hook Configuration

hook / hooks

Event listeners for monitoring and extending Agent behavior.

7. Structured Output

structuredOutputReminder

Reminder mode for structured output.

8. Tool Execution Context

toolExecutionContext

Hidden context object passed to tools.
Purpose:
  • Pass user identity information
  • Provide database connections
  • Inject configuration objects
  • Pass request context
Usage in Tools:

9. Plan Management (PlanNotebook)

planNotebook

PlanNotebook provides structured planning capabilities for Agents, suitable for complex multi-step tasks. It allows Agents to create, modify, and track plans through tool functions, and automatically injects contextual hints through the Hook mechanism. Core Features:
  • Plan Management: Create, revise, and complete multi-subtask plans
  • Auto Hint Injection: Automatically inject contextual hints before each reasoning step
  • State Tracking: Track subtask states (todo/in_progress/done/abandoned)
  • Historical Plans: Store and recover historical plans
Configuration Method 1: Quick Enable (Default Configuration)
Configuration Method 2: Custom Configuration

10. Formatter Configuration

Formatter is responsible for converting between AgentScope format and model API format.
Formatters for Different Models:
Generally, there’s no need to explicitly specify; the model will automatically select the appropriate Formatter.

11. Skill Configuration

skillBox (Optional)

Provides the set of skills available to the Agent. It allows the Agent to load skills through tool functions and automatically injects skill hints via the Hook mechanism.
Purpose:
  • Empower Agent to use skills
  • Control skill loading and usage through the skill set
  • Support dynamic loading and unloading of skills

Comprehensive Configuration Example

The following example demonstrates the complete usage of all core configuration options:

For detailed parameter configuration, please refer to the corresponding documentation.