Skip to content

Commit 3c764fd

Browse files
committed
fix(harness): allow MemoryFlushMiddleware to flush for all Agent types
MemoryFlushMiddleware.doFlush() checked `instanceof ReActAgent` before flushing memories, which silently skipped HarnessAgent (it implements Agent directly, not via ReActAgent). This caused daily memory journals (MEMORY type) and consolidated MEMORY.md (CONTEXT type) to never be written for HarnessAgent-based agents. Remove the ReActAgent type guard since RuntimeContext.resolveAgentState() accepts any Agent, and HarnessAgent provides getAgentState() via its delegate. Closes #2030
1 parent 325b7fe commit 3c764fd

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

agentscope-harness/src/main/java/io/agentscope/harness/agent/middleware/MemoryFlushMiddleware.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package io.agentscope.harness.agent.middleware;
1717

18-
import io.agentscope.core.ReActAgent;
1918
import io.agentscope.core.agent.Agent;
2019
import io.agentscope.core.agent.RuntimeContext;
2120
import io.agentscope.core.event.AgentEvent;
@@ -156,10 +155,7 @@ public Flux<AgentEvent> onAgent(
156155
}
157156

158157
private Mono<Void> doFlush(Agent agent, RuntimeContext rc) {
159-
if (!(agent instanceof ReActAgent reActAgent)) {
160-
return Mono.empty();
161-
}
162-
AgentState state = RuntimeContext.resolveAgentState(rc, reActAgent);
158+
AgentState state = RuntimeContext.resolveAgentState(rc, agent);
163159
if (state == null) {
164160
return Mono.empty();
165161
}
@@ -216,7 +212,7 @@ private Mono<Void> doFlush(Agent agent, RuntimeContext rc) {
216212
* namespace (see {@link #timerKeyFor(RuntimeContext)}).
217213
*
218214
* <p>Package-private for unit testing of the trigger gate without standing up a full
219-
* {@code ReActAgent}.
215+
* {@code Agent}.
220216
*/
221217
boolean shouldFlushNow(RuntimeContext rc) {
222218
switch (flushTrigger.mode()) {

0 commit comments

Comments
 (0)