Skip to content

Commit 4410d07

Browse files
committed
Merge remote-tracking branch 'upstream/main' into dev/0129/molt
2 parents 04955e9 + 7045c42 commit 4410d07

68 files changed

Lines changed: 759 additions & 2624 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@
9595
>
9696
> **About Framework-Agnostic**: Currently, AgentScope Runtime supports the **AgentScope** framework. We plan to extend compatibility to more agent development frameworks in the future. This table shows the current version’s adapter support for different frameworks. The level of support for each functionality varies across frameworks:
9797
>
98-
> | Framework/Feature | Message/Event | Tool | Service |
99-
> | ------------------------------------------------------------ | ------------- | ---- | ------- |
100-
> | [AgentScope](https://runtime.agentscope.io/en/quickstart.html) ||||
101-
> | [LangGraph](https://runtime.agentscope.io/en/langgraph_guidelines.html) || 🚧 | 🚧 |
102-
> | [Microsoft Agent Framework](https://runtime.agentscope.io/en/ms_agent_framework_guidelines.html) ||| 🚧 |
103-
> | [Agno](https://runtime.agentscope.io/en/agno_guidelines.html) ||| 🚧 |
104-
> | AutoGen | 🚧 || 🚧 |
98+
> | Framework/Feature | Message/Event | Tool |
99+
> | ------------------------------------------------------------ | ------------- | ---- |
100+
> | [AgentScope](https://runtime.agentscope.io/en/quickstart.html) |||
101+
> | [LangGraph](https://runtime.agentscope.io/en/langgraph_guidelines.html) || 🚧 |
102+
> | [Microsoft Agent Framework](https://runtime.agentscope.io/en/ms_agent_framework_guidelines.html) |||
103+
> | [Agno](https://runtime.agentscope.io/en/agno_guidelines.html) |||
104+
> | AutoGen | 🚧 ||
105105
106106
---
107107

@@ -155,14 +155,11 @@ from agentscope.formatter import DashScopeChatFormatter
155155
from agentscope.tool import Toolkit, execute_python_code
156156
from agentscope.pipeline import stream_printing_messages
157157
from agentscope.memory import InMemoryMemory
158+
from agentscope.session import RedisSession
158159

159160
from agentscope_runtime.engine import AgentApp
160161
from agentscope_runtime.engine.schemas.agent_schemas import AgentRequest
161162

162-
from agentscope_runtime.engine.services.agent_state import (
163-
InMemoryStateService,
164-
)
165-
166163
agent_app = AgentApp(
167164
app_name="Friday",
168165
app_description="A helpful assistant",
@@ -171,14 +168,13 @@ agent_app = AgentApp(
171168

172169
@agent_app.init
173170
async def init_func(self):
174-
self.state_service = InMemoryStateService()
175-
176-
await self.state_service.start()
177-
171+
import fakeredis
178172

179-
@agent_app.shutdown
180-
async def shutdown_func(self):
181-
await self.state_service.stop()
173+
fake_redis = fakeredis.aioredis.FakeRedis(decode_responses=True)
174+
# NOTE: This FakeRedis instance is for development/testing only.
175+
# In production, replace it with your own Redis client/connection
176+
# (e.g., aioredis.Redis)
177+
self.session = RedisSession(connection_pool=fake_redis.connection_pool)
182178

183179

184180
@agent_app.query(framework="agentscope")
@@ -191,11 +187,6 @@ async def query_func(
191187
session_id = request.session_id
192188
user_id = request.user_id
193189

194-
state = await self.state_service.export_state(
195-
session_id=session_id,
196-
user_id=user_id,
197-
)
198-
199190
toolkit = Toolkit()
200191
toolkit.register_tool_function(execute_python_code)
201192

@@ -213,21 +204,22 @@ async def query_func(
213204
)
214205
agent.set_console_output_enabled(enabled=False)
215206

216-
if state:
217-
agent.load_state_dict(state)
207+
await self.session.load_session_state(
208+
session_id=session_id,
209+
user_id=user_id,
210+
agent=agent,
211+
)
218212

219213
async for msg, last in stream_printing_messages(
220214
agents=[agent],
221215
coroutine_task=agent(msgs),
222216
):
223217
yield msg, last
224218

225-
state = agent.state_dict()
226-
227-
await self.state_service.save_state(
228-
user_id=user_id,
219+
await self.session.save_session_state(
229220
session_id=session_id,
230-
state=state,
221+
user_id=user_id,
222+
agent=agent,
231223
)
232224

233225

README_zh.md

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@
9696
>
9797
> **关于框架无关**:当前,AgentScope Runtime 支持 **AgentScope** 框架。未来我们计划扩展支持更多智能体开发框架。该表格展示了目前版本针对不同框架的适配器(adapter)支持情况,不同框架在各功能上的支持程度有所差异:
9898
>
99-
> | 框架 / 功能项 | 消息 / 事件 | 工具 | 服务 |
100-
> | ------------------------------------------------------------ | ------------- | ---- | ------- |
101-
> | [AgentScope](https://runtime.agentscope.io/zh/quickstart.html) ||||
102-
> | [LangGraph](https://runtime.agentscope.io/zh/langgraph_guidelines.html) || 🚧 | 🚧 |
103-
> | [Microsoft Agent Framework](https://runtime.agentscope.io/zh/ms_agent_framework_guidelines.html) ||| 🚧 |
104-
> | [Agno](https://runtime.agentscope.io/zh/agno_guidelines.html) ||| 🚧 |
105-
> | AutoGen | 🚧 || 🚧 |
99+
> | 框架 / 功能项 | 消息 / 事件 | 工具 |
100+
> | ------------------------------------------------------------ | ------------- | ---- |
101+
> | [AgentScope](https://runtime.agentscope.io/zh/quickstart.html) |||
102+
> | [LangGraph](https://runtime.agentscope.io/zh/langgraph_guidelines.html) || 🚧 |
103+
> | [Microsoft Agent Framework](https://runtime.agentscope.io/zh/ms_agent_framework_guidelines.html) |||
104+
> | [Agno](https://runtime.agentscope.io/zh/agno_guidelines.html) |||
105+
> | AutoGen | 🚧 ||
106106
107107
---
108108

@@ -157,14 +157,11 @@ from agentscope.formatter import DashScopeChatFormatter
157157
from agentscope.tool import Toolkit, execute_python_code
158158
from agentscope.pipeline import stream_printing_messages
159159
from agentscope.memory import InMemoryMemory
160+
from agentscope.session import RedisSession
160161

161162
from agentscope_runtime.engine import AgentApp
162163
from agentscope_runtime.engine.schemas.agent_schemas import AgentRequest
163164

164-
from agentscope_runtime.engine.services.agent_state import (
165-
InMemoryStateService,
166-
)
167-
168165
agent_app = AgentApp(
169166
app_name="Friday",
170167
app_description="A helpful assistant",
@@ -173,14 +170,13 @@ agent_app = AgentApp(
173170

174171
@agent_app.init
175172
async def init_func(self):
176-
self.state_service = InMemoryStateService()
177-
178-
await self.state_service.start()
179-
173+
import fakeredis
180174

181-
@agent_app.shutdown
182-
async def shutdown_func(self):
183-
await self.state_service.stop()
175+
fake_redis = fakeredis.aioredis.FakeRedis(decode_responses=True)
176+
# 注意:这个 FakeRedis 实例仅用于开发/测试。
177+
# 在生产环境中,请替换为你自己的 Redis 客户端/连接
178+
#(例如 aioredis.Redis)。
179+
self.session = RedisSession(connection_pool=fake_redis.connection_pool)
184180

185181

186182
@agent_app.query(framework="agentscope")
@@ -193,11 +189,6 @@ async def query_func(
193189
session_id = request.session_id
194190
user_id = request.user_id
195191

196-
state = await self.state_service.export_state(
197-
session_id=session_id,
198-
user_id=user_id,
199-
)
200-
201192
toolkit = Toolkit()
202193
toolkit.register_tool_function(execute_python_code)
203194

@@ -215,21 +206,22 @@ async def query_func(
215206
)
216207
agent.set_console_output_enabled(enabled=False)
217208

218-
if state:
219-
agent.load_state_dict(state)
209+
await self.session.load_session_state(
210+
session_id=session_id,
211+
user_id=user_id,
212+
agent=agent,
213+
)
220214

221215
async for msg, last in stream_printing_messages(
222216
agents=[agent],
223217
coroutine_task=agent(msgs),
224218
):
225219
yield msg, last
226220

227-
state = agent.state_dict()
228-
229-
await self.state_service.save_state(
230-
user_id=user_id,
221+
await self.session.save_session_state(
231222
session_id=session_id,
232-
state=state,
223+
user_id=user_id,
224+
agent=agent,
233225
)
234226

235227

cookbook/_toc.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ parts:
1111
sections:
1212
- file: en/sandbox/sandbox.md
1313
sections:
14+
- file: en/sandbox/sandbox_service.md
1415
- file: en/sandbox/advanced.md
1516
- file: en/sandbox/training_sandbox.md
1617
- file: en/sandbox/troubleshooting.md
@@ -21,10 +22,6 @@ parts:
2122
- file: en/tools/modelstudio_generations.md
2223
- file: en/tools/alipay.md
2324
- file: en/tools/realtime_clients.md
24-
- file: en/service/service.md
25-
sections:
26-
- file: en/service/sandbox.md
27-
- file: en/service/state.md
2825
- file: en/deployment.md
2926
sections:
3027
- file: en/agent_app.md
@@ -73,6 +70,7 @@ parts:
7370
sections:
7471
- file: zh/sandbox/sandbox.md
7572
sections:
73+
- file: zh/sandbox/sandbox_service.md
7674
- file: zh/sandbox/advanced.md
7775
- file: zh/sandbox/training_sandbox.md
7876
- file: zh/sandbox/troubleshooting.md
@@ -83,10 +81,6 @@ parts:
8381
- file: zh/tools/modelstudio_generations.md
8482
- file: zh/tools/alipay.md
8583
- file: zh/tools/realtime_clients.md
86-
- file: zh/service/service.md
87-
sections:
88-
- file: zh/service/sandbox.md
89-
- file: zh/service/state.md
9084
- file: zh/deployment.md
9185
sections:
9286
- file: zh/agent_app.md

cookbook/en/advanced_deployment.md

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,10 @@ from agentscope.model import DashScopeChatModel
110110
from agentscope.pipeline import stream_printing_messages
111111
from agentscope.tool import Toolkit, execute_python_code
112112
from agentscope.memory import InMemoryMemory
113+
from agentscope.session import RedisSession
113114
114115
from agentscope_runtime.engine.app import AgentApp
115116
from agentscope_runtime.engine.schemas.agent_schemas import AgentRequest
116-
from agentscope_runtime.engine.services.agent_state import (
117-
InMemoryStateService,
118-
)
119117
120118
app = AgentApp(
121119
app_name="Friday",
@@ -125,13 +123,13 @@ app = AgentApp(
125123
126124
@app.init
127125
async def init_func(self):
128-
self.state_service = InMemoryStateService()
129-
await self.state_service.start()
130-
126+
import fakeredis
131127
132-
@app.shutdown
133-
async def shutdown_func(self):
134-
await self.state_service.stop()
128+
fake_redis = fakeredis.aioredis.FakeRedis(decode_responses=True)
129+
# NOTE: This FakeRedis instance is for development/testing only.
130+
# In production, replace it with your own Redis client/connection
131+
# (e.g., aioredis.Redis)
132+
self.session = RedisSession(connection_pool=fake_redis.connection_pool)
135133
136134
137135
@app.query(framework="agentscope")
@@ -145,11 +143,6 @@ async def query_func(
145143
session_id = request.session_id
146144
user_id = request.user_id
147145
148-
state = await self.state_service.export_state(
149-
session_id=session_id,
150-
user_id=user_id,
151-
)
152-
153146
toolkit = Toolkit()
154147
toolkit.register_tool_function(execute_python_code)
155148
@@ -167,21 +160,22 @@ async def query_func(
167160
formatter=DashScopeChatFormatter(),
168161
)
169162
170-
if state:
171-
agent.load_state_dict(state)
163+
await self.session.load_session_state(
164+
session_id=session_id,
165+
user_id=user_id,
166+
agent=agent,
167+
)
172168
173169
async for msg, last in stream_printing_messages(
174170
agents=[agent],
175171
coroutine_task=agent(msgs),
176172
):
177173
yield msg, last
178174
179-
state = agent.state_dict()
180-
181-
await self.state_service.save_state(
182-
user_id=user_id,
175+
await self.session.save_session_state(
183176
session_id=session_id,
184-
state=state,
177+
user_id=user_id,
178+
agent=agent,
185179
)
186180
187181

0 commit comments

Comments
 (0)