agentscope-ai / agentscope-ai/agentscope-runtime

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

Đang mở
#293 4 bình luận 0 reaction 1 người được giao Được @zhilingluo nhận Xem trên GitHub
enhancement
Ngôn ngữ chính
Python
Star
863
Fork
168
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.