Repository navigation
fix(harness): stop sync-spawned subagents on parent cancel - #2412
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
oss-maintainer
left a comment
There was a problem hiding this comment.
✅ Approved — Clean, focused fix for #2408.
Two key changes both look correct:
- HarnessAgent delegate unwrapping in
interruptAgent()— properly routes cancellation through the facade to the underlyingReActAgent - Child session context — uses
childContextwith the correctsub-*session ID instead of the parent'sruntimeContext, which was the secondary bug
Good regression test coverage including the HarnessAgent delegation path and session context identity check. The scope is well-contained to AgentSpawnTool without touching the shared interrupt API.
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR fixes an orphan sub-agent memory leak in AgentSpawnTool.execWithTimeoutPromotion. When a parent agent's subscription is cancelled, the spawned child agent was not properly interrupted because: (1) the parent's RuntimeContext was passed to interruptAgent, targeting the wrong session; (2) HarnessAgent instances were not handled by the instanceof check. The fix constructs a childContext with the correct (userId, sessionId) and adds HarnessAgent delegate unwrapping.
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR fixes an orphan sub-agent memory leak in AgentSpawnTool.execWithTimeoutPromotion. When a parent agent's subscription is cancelled, the spawned child agent was not properly interrupted because: (1) the parent's RuntimeContext was passed to interruptAgent, targeting the wrong session; (2) HarnessAgent instances were not handled by the instanceof check. The fix constructs a childContext with the correct (userId, sessionId) and adds HarnessAgent delegate unwrapping.
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR fixes an orphan sub-agent memory leak in AgentSpawnTool.execWithTimeoutPromotion. When a parent agent's subscription is cancelled, the spawned child agent was not properly interrupted because: (1) the parent's RuntimeContext was passed to interruptAgent, targeting the wrong session; (2) HarnessAgent instances were not handled by the instanceof check. The fix constructs a childContext with the correct (userId, sessionId) and adds HarnessAgent delegate unwrapping.
Summary
HarnessAgentto itsReActAgentdelegatesub-*session context instead of the parent run contextAgentimplementations and timeout promotion behaviorRoot cause
AgentSpawnTool.interruptAgentonly handled directReActAgentinstances, so a synchronously spawnedHarnessAgentignored parent cancellation. It also calledinterruptwith the parentRuntimeContext, while the child runs under a newly generatedsub-*session.This fix stays local to
AgentSpawnTooland does not change the sharedAgentinterrupt API or theHarnessAgentfacade, avoiding overlap with #1685 and #1990.Tests
HarnessAgentdelegate interruption.RuntimeContextidentity.Agentsubscriptions are still disposed.mvn spotless:checkmvn test -DargLine='-Djava.awt.headless=true -javaagent:/Users/jinjichang/.m2/repository/org/mockito/mockito-core/5.23.0/mockito-core-5.23.0.jar -Xms512m -Xmx1024m'(all 82 reactor modules passed)Closes #2408