agentscope-ai / agentscope-ai/agentscope-runtime

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

Aperta
#306 0 commenti 0 reazioni 1 assegnatario Rivendicata da @rayrayraykk Vedi su GitHub
Discussion enhancement
Lingua principale
Python
Stelle
863
Fork
168
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.