Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cookbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -q -e ".[dev,langgraph,agno,a2a,autogen,aliyun_tablestore_ext,memory_ext]"
pip install -q -e ".[dev,ext]"
- name: Add execute permission to build.sh
run: |
chmod +x cookbook/build.sh
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/integrated_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- 'main'
- 'dev'


jobs:
Expand Down Expand Up @@ -61,7 +62,7 @@ jobs:
- name: Install dependencies
run: |
export PIP_DEFAULT_TIMEOUT=300
pip install -q -e ".[dev,langgraph,agno,autogen,langchain_rag,llamaindex_rag,aliyun_tablestore_ext,memory_ext]"
pip install -q -e ".[dev,ext]"

- name: Run integrated tests with coverage
env:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- 'main'
- 'dev'
pull_request:
branches:
- 'main'
- 'dev'

jobs:
test:
Expand Down Expand Up @@ -48,7 +50,7 @@ jobs:
- name: Install dependencies
run: |
export PIP_DEFAULT_TIMEOUT=300
pip install -q -e ".[dev,langchain_rag,llamaindex_rag,aliyun_tablestore_ext,memory_ext]"
pip install -q -e ".[dev,ext]"

- name: Run tests with coverage
run: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/unit_test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- 'main'
- 'dev'
pull_request:
branches:
- 'main'
- 'dev'

jobs:
test:
Expand Down Expand Up @@ -48,7 +50,7 @@ jobs:
- name: Install dependencies
run: |
export PIP_DEFAULT_TIMEOUT=300
pip install -q -e ".[dev,langchain_rag,llamaindex_rag,aliyun_tablestore_ext,memory_ext,deployment]"
pip install -q -e ".[dev,ext]"

- name: Run tests with coverage
run: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/unit_test_sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- 'main'
- 'dev'
pull_request:
branches:
- 'main'
- 'dev'

jobs:
test:
Expand Down Expand Up @@ -67,7 +69,7 @@ jobs:

- name: Run tests with coverage
run: |
coverage run -m pytest tests/sandbox/test_sandbox.py tests/sandbox/test_tool.py
coverage run -m pytest tests/sandbox/test_sandbox.py tests/sandbox/test_sandbox_service.py

- name: Generate coverage report
run: |
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/unit_test_tool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ on:
push:
branches:
- 'main'
- 'dev'
pull_request:
branches:
- 'main'
- 'dev'

jobs:
test:
Expand Down Expand Up @@ -45,11 +50,11 @@ jobs:
- name: Install dependencies
run: |
export PIP_DEFAULT_TIMEOUT=300
pip install -q -e ".[dev,tool]"
pip install -q -e ".[dev,ext]"

- name: Run tests with coverage
run: |
coverage run -m pytest tests/unit
coverage run -m pytest tests/tools

- name: Generate coverage report
run: |
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/unit_test_training_sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- 'main'
- 'dev'
pull_request:
branches:
- 'main'
- 'dev'

jobs:
test:
Expand Down Expand Up @@ -49,7 +51,6 @@ jobs:
- name: Pull Docker images
run: |
DOCKER_IMAGES=(
"agentscope/runtime-sandbox-bfcl:latest"
"agentscope/runtime-sandbox-appworld:latest"
)

Expand Down Expand Up @@ -83,7 +84,7 @@ jobs:

- name: Run tests with coverage
run: |
coverage run -m pytest tests/sandbox/test_sandbox_appworld.py tests/sandbox/test_sandbox_bfcl.py
coverage run -m pytest tests/sandbox/test_sandbox_appworld.py

- name: Generate coverage report
run: |
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@

**A Production-Ready Runtime Framework for Intelligent Agent Applications**

*AgentScope Runtime tackles two critical challenges in agent development: secure sandboxed tool execution and scalable agent deployment. Built with a dual-core architecture, it provides framework-agnostic infrastructure for deploying agents with full observability and safe tool interactions. In addition, the tools module offers a variety of out-of-the-box tools, which are adapted by the framework’s adapters for seamless compatibility with different native intelligent agent frameworks, ensuring developers can retain their original development experience.*
***AgentScope Runtime** is a full-stack agent runtime that tackles two core challenges: **efficient agent deployment** and **secure sandbox execution**. It ships with foundational services such as short- and long-term memory plus agent state persistence, along with hardened sandbox infrastructure. Whether you need to orchestrate production-grade agents or guarantee safe tool interactions, AgentScope Runtime provides developer-friendly workflows with complete observability.*

*In V1.0, these services are exposed via an **adapter pattern**, enabling seamless integration with the native modules of different agent frameworks while preserving their native interfaces and behaviors, ensuring both compatibility and flexibility.*

</div>

---

## 🆕 NEWS

* **[2025-11]** We released **<u>AgentScope Runtime V1.0</u>**, which ensures the native development experience of agent frameworks, allowing them to fully leverage their expressive power. In this version, we further simplified certain abstractions and modules to streamline the architecture. For the complete list of changes, please refer to the changelog.
* **[2025-12]** We have released **AgentScope Runtime v1.0**, introducing a unified “Agent as API” white-box development experience, with enhanced multi-agent collaboration, state persistence, and cross-framework integration. This release also streamlines abstractions and modules to ensure consistency between development and production environments. Please refer to the **[CHANGELOG](https://runtime.agentscope.io/en/CHANGELOG.html)** for full update details and migration guide.

---

Expand Down Expand Up @@ -85,6 +87,9 @@ From PyPI:
# Install core dependencies
pip install agentscope-runtime

# Install extension
pip install "agentscope-runtime[ext]"

# Install preview version
pip install --pre agentscope-runtime
```
Expand Down
9 changes: 7 additions & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@

**智能体应用的生产就绪运行时框架**

*AgentScope Runtime 解决了智能体开发中的两个关键挑战:安全的沙盒化工具执行和可扩展的智能体部署。其双核心架构为智能体提供了与框架无关的基础设施,支持在部署过程中实现完整的可观测性和安全的工具交互。此外,工具模块提供了丰富的开箱即用工具,并通过适配器适配到不同的原生智能体框架,从而确保兼容性,同时保留原有的开发体验。*
***AgentScope Runtime** 是一个全面的智能体运行时框架,旨在解决两个关键挑战:**高效的智能体部署**和**沙箱执行**。它内置了基础服务(长短期记忆、智能体状态持久化)和安全沙箱基础设施。无论您需要大规模部署智能体还是确保安全的工具交互,AgentScope Runtime 都能提供具有完整可观测性和开发者友好部署的核心基础设施。*

*在 V1.0 中,这些运行时服务通过 **适配器模式** 对外开放,允许开发者在保留原有智能体框架接口与行为的基础上,将 AgentScope 的状态管理、会话记录、工具调用等模块按需嵌入到应用生命周期中。从过去的 “黑盒化替换” 变为 “白盒化集成”,开发者可以显式地控制服务初始化、工具注册与状态持久化流程,从而在不同框架间实现无缝整合,同时获得更高的扩展性与灵活性。*

</div>

---

## 🆕 新闻

* **[2025-11]** 我们发布了 **AgentScope Runtime V1.0**,该版本保证了 agent 框架的原生开发体验,从而能够最大程度发挥其表达能力。同时,我们对部分抽象及模块进行了进一步简化,以优化整体架构。完整更新内容请参考 changelog
* **[2025-12]** 我们发布了 **AgentScope Runtime v1.0**,该版本引入统一的 “Agent 作为 API” 白盒化开发体验,并全面强化多智能体协作、状态持久化与跨框架组合能力,同时对抽象与模块进行了简化优化,确保开发与生产环境一致性。完整更新内容与迁移说明请参考 **[CHANGELOG](https://runtime.agentscope.io/zh/CHANGELOG.html)**

---

Expand Down Expand Up @@ -85,6 +87,9 @@
# 安装核心依赖
pip install agentscope-runtime

# 安装拓展
pip install "agentscope-runtime[ext]"

# 安装预览版本
pip install --pre agentscope-runtime
```
Expand Down
2 changes: 1 addition & 1 deletion cookbook/en/advanced_deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Install AgentScope Runtime with all deployment dependencies:
pip install agentscope-runtime>=1.0.0

# For Kubernetes deployment
pip install "agentscope-runtime[deployment]>=1.0.0"
pip install "agentscope-runtime[ext]>=1.0.0"
```

### 🔑 Environment Setup
Expand Down
104 changes: 80 additions & 24 deletions cookbook/en/agent_app.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ kernelspec:

# Simple Deployment

`AgentApp` is the all-in-one agent service wrapper in **AgentScope Runtime**. Any agent that matches its interface can be exposed as an API service supporting:
`AgentApp` is the all-in-one application service wrapper in **AgentScope Runtime**.
It provides the HTTP service framework for your agent logic and can expose it as an API with features such as:

- Streaming responses (SSE)
- Health-check endpoints
- Lifecycle hooks (`before_start` / `after_finish`)
- Celery asynchronous task queues
- Deployments to local or remote targets
- **Streaming responses (SSE)** for real-time output
- Built-in **health-check** endpoints
- **Lifecycle hooks** (`@app.init` / `@app.shutdown`) for startup and cleanup logic
- Optional **Celery** asynchronous task queues
- Deployment to local or remote targets

**Important**:
In the current version, `AgentApp` does not automatically include a `/process` endpoint.
You must explicitly register a request handler using decorators (e.g., `@app.query(...)`) before your service can process incoming requests.

The sections below dive into each capability with concrete examples.

Expand All @@ -30,30 +35,31 @@ The sections below dive into each capability with concrete examples.

**What it does**

Starts an HTTP API service that wraps your agent, listens on the configured port, and serves the primary handler (default `/process`).
Creates a minimal `AgentApp` instance and starts a FastAPI-based HTTP service skeleton.
In its initial state, the service only provides:

- Welcome page `/`
- Health check `/health`
- Readiness probe `/readiness`
- Liveness probe `/liveness`

**Note**:

- By default, no `/process` or other business endpoints are exposed.
- You **must** register at least one handler using decorators such as `@app.query(...)` or `@app.task(...)` before the service can process requests.
- Handlers can be regular or async functions, and may support streaming output via async generators.

**Example**

```{code-cell}
from agentscope_runtime.engine import AgentApp
from agentscope_runtime.engine.agents.agentscope_agent import AgentScopeAgent
from agentscope.model import OpenAIChatModel
from agentscope.agent import ReActAgent

# Build an Agent
agent = AgentScopeAgent(
name="Friday",
model=OpenAIChatModel(
"gpt-4",
api_key="YOUR_OPENAI_KEY",
),
agent_config={"sys_prompt": "You are a helpful assistant."},
agent_builder=ReActAgent,
agent_app = AgentApp(
app_name="Friday",
app_description="A helpful assistant",
)

# Create and launch AgentApp
app = AgentApp(agent=agent, endpoint_path="/process", response_type="sse", stream=True)
app.run(host="0.0.0.0", port=8090)
agent_app.run(host="127.0.0.1", port=8090)
```

------
Expand Down Expand Up @@ -122,7 +128,11 @@ app = AgentApp(

### Method 2: Use Decorators (Recommended)

Decorators are more flexible and keep the logic close to the app definition:
In addition to passing hook functions via constructor parameters, you can also register lifecycle hooks using decorators.
This approach has the following advantages:

1. **More flexible and intuitive** — The lifecycle logic is placed directly alongside the application definition, making the structure clearer and code more readable.
2. **Shared member variables** — Functions defined with decorators receive `self`, allowing access to the attributes and services of the `AgentApp` instance (for example, state services or session services started in `@app.init`), enabling convenient sharing and reuse of resources across different lifecycle stages or request handlers.

```{code-cell}
from agentscope_runtime.engine import AgentApp
Expand Down Expand Up @@ -429,7 +439,7 @@ async def query_func(
app.run(host="0.0.0.0", port=8090)
```

### Comparison with the `agent` Parameter Approach
### Comparison with the V0 version`agent` Parameter Approach

| Feature | Pre-built `agent` Parameter | Custom `@app.query` |
|---------|----------------------------|---------------------|
Expand All @@ -440,6 +450,52 @@ app.run(host="0.0.0.0", port=8090)

------

## Custom Endpoints via `@app.endpoint`

In addition to using `@app.query(...)` for the unified `/process` entry point, `AgentApp` also supports registering arbitrary HTTP endpoints via the `@app.endpoint(...)` decorator.

**Key Features**:

1. **High flexibility** — Define dedicated API paths for different business needs, rather than routing all traffic through `/process`.

2. Multiple return modes— Supports:

- Regular sync/async functions returning JSON
- Generators (sync or async) returning **streaming data** over SSE

3. Automatic parameter parsing— Endpoints can accept:

- URL query parameters
- JSON bodies mapped to Pydantic models
- `fastapi.Request` objects
- `AgentRequest` objects (convenient for accessing unified session/user info)

4. **Error handling** — Exceptions raised in streaming generators are automatically wrapped into SSE error events and sent to the client.

**Example**:

```python
app = AgentApp()

@app.endpoint("/hello")
def hello_endpoint():
return {"msg": "Hello world"}

@app.endpoint("/stream_numbers")
async def stream_numbers():
for i in range(5):
yield f"number: {i}\n"
```

Client calls:

```bash
curl -X POST http://localhost:8090/hello
curl -X POST http://localhost:8090/stream_numbers
```

---

## Deploy Locally or Remotely

Use the unified `deploy()` method to ship the same app to different environments:
Expand Down
12 changes: 8 additions & 4 deletions cookbook/en/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ To install the stable release of Agentscope Runtime via PyPI, use:

```bash
pip install agentscope-runtime

# For additional extensions, install with extras:
pip install "agentscope-runtime[ext]"
```

### (Optional) Install preview version (Beta/RC)
Expand Down Expand Up @@ -75,8 +78,9 @@ You should see the version number printed out.

The core runtime (`agentscope-runtime`) includes AgentScope Framework and Sandbox dependencies. See details about all installation options at [pyproject.toml](https://github.com/agentscope-ai/agentscope-runtime/blob/main/pyproject.toml).

| **Component** | **Package** | **Use-Case** | **Dependencies** |
| --------------------- | -------------------- | ------------- | ------------------------------------------------------------ |
| Core Runtime | `agentscope-runtime` | Core runtime | Minimal including AgentScope Framework and Sandbox Dependencies |
| Development Tools | `dev` | Dev utilities | Testing, Linting, Docs |
| **Component** | **Package** | **Use-Case** | **Dependencies** |
| ----------------- | -------------------- | ------------- | ------------------------------------------------------------ |
| Core Runtime | `agentscope-runtime` | Core runtime | Minimal including AgentScope Framework and Sandbox Dependencies |
| Development Tools | `dev` | Dev utilities | Testing, Linting, Docs |
| Extention | `ext` | Deployment | REME AI, Mem0, Alibaba Cloud services, TableStore, LangChain, Azure Speech, OSS, Authentication, Build tools |

2 changes: 1 addition & 1 deletion cookbook/en/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ is_healthy = await sandbox_service.health()
await sandbox_service.stop()
```

See {doc}`sandbox` for details.
See {doc}`sandbox/sandbox` for details.

### StateService

Expand Down
Loading
Loading