agentscope-ai / agentscope-ai/agentscope-runtime

[Feature Request] Add Agent Runner Builder Helper to simplify agentapp building process

未关闭
#306 0 条评论 0 个 reaction 已指派 1 人 已被 @rayrayraykk 认领 在 GitHub 查看
Discussion enhancement
主要语言
Python
星标
863
派生
168
PR 合并指标
30 天内没有已合并 PR

描述

## Problem Description

Building an AgentApp currently requires writing a large amount of repetitive boilerplate code.
Even simple agent setups require manually handling:

• Engine initialization
• State service and session history setup
• Lifecycle hooks (init/shutdown)
• Query function structure
• Agent construction (model, tools, memory, formatter)
• SSE response streaming logic
• State load/save

These steps are repetitive, error‑prone, and make common scenarios unnecessarily complex.
Most developers follow nearly identical patterns, but still must write 100+ lines of setup code.

## Proposed Solution: **Runner Builder Helper**

Instead of an Agent Builder, introduce a **Runner Builder Helper**
(e.g., `AgentRunnerHelper`, `RunnerBuilder`, or `AgentRunnerBuilder`)
to encapsulate *all* the boilerplate code required to construct a fully working AgentApp and Runner.

The helper should:

• Automatically configure default services (state, session history, memory)
• Provide simple arguments or builder‑style APIs for customization (model, tools, prompts, formatter)
• Auto‑register lifecycle hooks
• Auto‑bind a standard query handler with SSE streaming enabled
• Allow overrides for advanced scenarios
• Return a fully initialized Runner, ready to `run()`

This reduces the setup to a few intuitive lines:

```python
helper = AgentRunnerHelper(
name="Friday",
model="qwen-turbo",
tools=[execute_python_code],
system_prompt="You're a helpful assistant named Friday.",
)

runner = helper.build()
app = AgentApp(runner=runner)
app.run(port=8000)
```

## What the Runner Builder Does Internally

The Runner Builder hides all complex logic that developers currently write manually.
Internally, it automatically performs:

• Creation of the Runner
• Registration of init and shutdown lifecycle hooks
• Initialization of InMemoryStateService
• Initialization of InMemorySessionHistoryService
• Construction of a ReActAgent
• Tool registration
• Binding of the default query handler
• Handling of SSE streaming output
• Loading and saving of agent state
• Construction of the Runner and returning it to the user

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。