agentscope-ai / agentscope-ai/agentscope-java

[Bug]:在MiddlewareBase的onAgent中,agent参数没有getRuntimeContext

Đang mở
#1,672 4 bình luận 0 reaction 0 người được giao Xem trên GitHub
area/core/agent bug
Ngôn ngữ chính
Java
Star
5.6k
Fork
1.3k
Merge trung bình
4 ngày 12 giờ
Pull request đã merge (30 ngày)
77

Mô tả

**Describe the bug**
The `Agent` object passed as a parameter into the `onAgent` method of `MiddlewareBase` lacks the `getRuntimeContext()` method (or the runtime context is null/inaccessible). This prevents middleware implementations from accessing or modifying the runtime context during the agent's execution lifecycle.

**To Reproduce**
Steps to reproduce the behavior:

1. Implement a custom middleware by implementing the `MiddlewareBase` interface.
2. Override the `onAgent` method and attempt to access the runtime context via the `agent` parameter:
```java
@Override
public Flux onAgent(Agent agent, AgentInput input, Function> next) {
// Attempting to get runtime context here fails or returns null
// e.g., agent.getRuntimeContext()
return next.apply(input);
}
```
3. Register this middleware and trigger an agent execution.
4. See the missing method error or null pointer exception.

**Expected behavior**
The `Agent` parameter provided in the `onAgent` middleware hook should expose a valid `getRuntimeContext()` method (or equivalent API), allowing developers to retrieve and manipulate the runtime context for purposes like logging, tracing, or modifying agent behavior dynamically.

**Error messages**
`[Please paste the exact compilation error, NullPointerException, or missing method exception stack trace here]`

**Environment (please complete the following information):**

- AgentScope-Java Version: `2.0.0-RC1`
- Java Version: `25`
- OS: `Windows`

**Additional context**
This issue blocks the implementation of custom middleware that relies on runtime context (e.g., for security checks, multi-tenant isolation, or dynamic prompt injection as mentioned in the AgentScope 2.0 middleware documentation). Any workaround or timeline for fixing this API gap would be highly appreciated.

Image

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.