agentscope-ai / agentscope-ai/agentscope-java
[Bug]:在MiddlewareBase的onAgent中,agent参数没有getRuntimeContext
- 主要言語
- Java
- スター
- 5.6k
- フォーク
- 1.3k
- 平均マージ
- 4日 12時間
- マージ済み PR(30日)
- 77
説明
**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.
コントリビューションガイド
評価
この issue はまだ評価されていません。