agentscope-ai / agentscope-ai/agentscope-runtime

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

Ouverte
#306 0 commentaires 0 réactions 1 personne assignée Réclamée par @rayrayraykk Voir sur GitHub
Discussion enhancement
Langage dominant
Python
Étoiles
863
Forks
168
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

## 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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.