agentscope-ai / agentscope-ai/agentscope-runtime

[Feature] Add Hooks/Decorators for FastAPI Middleware in AgentApp

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

Descrizione

## Problem Description

Currently, `agentscope_runtime.engine.AgentApp` leverages `FastAPIAppFactory.create_app` to instantiate a FastAPI application instance for serving agent-related endpoints. However, there is no built-in mechanism (e.g., hooks, decorators, or callback functions) to inject custom FastAPI middleware into the created app instance.

Developers who need to add middleware (e.g., logging, authentication, ~~CORS~~ customization, request/response interceptors) to the FastAPI app have to either:
Modify the internal implementation of FastAPIAppFactory (not maintainable), or
Recreate the app instance manually (defeats the purpose of AgentApp abstraction).

## Proposed Solution

to be discussed.

## Affected Component(s)
- [x] Engine
- [ ] Sandbox
- [ ] Common
- [ ] Tools
- [ ] Documentation
- [ ] Other: ___________

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.