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
ReActAgent (Recommended)
Reasoning + Acting, a general-purpose Agent combining reasoning and tool execution.- 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).- 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.- 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
memory (Recommended)
Stores conversation history, giving the Agent contextual memory.4. Tool Configuration
toolkit (Optional)
Provides the set of tools the Agent can invoke.- 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).checkRunning
Controls whether to check if the Agent is already running before accepting a new call.true
Behavior:
- When
true(default): Ifcall()is invoked while the Agent is still processing a previous request, anIllegalStateExceptionis thrown with the message “Agent is still running, please wait for it to finish” - When
false: Allows concurrentcall()invocations without checking the running state
checkRunning=true(default): Suitable for most scenarios, prevents state corruption from concurrent executioncheckRunning=false:- Stateless Agents that don’t maintain conversation state
- Scenarios requiring concurrent request processing
- Performance testing or load testing
- 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.ReActAgent’s reasoning phase (ReasoningPipeline), this configuration is injected into GenerateOptions:
- 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)
- 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.ReActAgent’s execution phase (ActingPipeline), this configuration is passed when calling toolkit.callTools():
- Timeout: 5 minutes
- Max attempts: 1 (no retry)
- 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
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.- Pass user identity information
- Provide database connections
- Inject configuration objects
- Pass request context
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
10. Formatter Configuration
Formatter is responsible for converting between AgentScope format and model API format.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.- 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.