agentscope-ai / agentscope-ai/agentscope-java
[Bug]:在MiddlewareBase的onAgent中,agent参数没有getRuntimeContext
- Lingua principale
- Java
- Stelle
- 5.6k
- Fork
- 1.3k
- Merge medio
- 4g 12h
- PR unite (30g)
- 77
Descrizione
**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.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.