Skip to main content
Agent is the core abstraction in AgentScope: a stateless reasoning-acting loop engine that integrates models, tools, the permission system, human-in-the-loop, context management, middlewares, state management, and the event system into a single unified interface. Its primary responsibilities are:
  • Accepting input messages or events, invoking tools to complete tasks
  • Generating structured output that conforms to a user-provided schema
  • Managing context, including context compression and offloading
  • Staying aware of the changing environment (time, tasks, context usage) via runtime state injection
  • Executing middleware hooks at key lifecycle stages for custom logic
  • Automatically managing concurrent and sequential tool execution
  • Handling user interruptions and continuing from paused states

Core Interfaces

The main interfaces of the Agent class are as follows:

Main Loop

The agent runs a reasoning-acting loop on every reply call. Each round, a single decision point inspects the current state and chooses the next action (reasoning, acting, or exit). The diagram below shows the main control flow.

Next Steps

Configure Agent

How to set up models, formatters, tools, and configs.

Run Agent

How to reply, stream, require structured output, and persist state.

Environment Awareness

How the agent stays aware of time, tasks, and context usage.

Interrupt Agent

How to stop a running or paused agent cleanly.

Human-in-the-Loop

How to pause for user confirmation or external execution.