agentscope-ai / agentscope-ai/agentscope-runtime

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

Offen
#293 4 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @zhilingluo Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Python
Sterne
863
Forks
168
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.