fix(core): promote interrupt(RuntimeContext) to Agent interface to fix slot-mismatch silent failure#1990
Open
Buktal wants to merge 1 commit into
Open
Conversation
…x slot-mismatch silent failure The Agent.interrupt() and Agent.interrupt(Msg) methods were hardcoded to the agent's defaultSessionId. When a call was made with a RuntimeContext carrying a different sessionId, calling agent.interrupt() from a middleware triggered the wrong session's InterruptControl — a silent no-op that neither threw nor logged anything. Add interrupt(RuntimeContext) and interrupt(RuntimeContext, Msg) as default methods on the Agent interface. ReActAgent overrides them with real per-session trigger logic (already existed, now @OverRide). HarnessAgent gains the missing delegates. Mark all legacy interrupt methods @deprecated(forRemoval = true). Closes agentscope-ai#1988, Closes agentscope-ai#1989
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
2.0.0-SNAPSHOT
Description
Problem: The
Agent.interrupt()andAgent.interrupt(Msg)methods were hardcoded to the agent'sdefaultSessionId. When a call was made with aRuntimeContextcarrying a differentsessionId, callingagent.interrupt()from a middleware triggered the wrong session'sInterruptControl— a silent no-op that neither threw nor logged anything. Middlewares holding bothAgent agentandRuntimeContext ctx(e.g.onModelCall,onReasoning) were forced to cast((ReActAgent) agent).interrupt(ctx), as seen inSubAgentTool.java:200-229.Solution: Add
interrupt(RuntimeContext)andinterrupt(RuntimeContext, Msg)as default methods on theAgentinterface.ReActAgentalready had these methods with real per-session trigger logic — now they properly@Overridethe interface methods.HarnessAgentgains the missing delegates so the methods work through the harness wrapper.Changes:
Agent.javadefault interrupt(RuntimeContext)/interrupt(RuntimeContext, Msg); mark old methods@Deprecated(forRemoval=true)AgentBase.javaforRemoval=trueReActAgent.java@Overrideto existinginterrupt(RuntimeContext)/interrupt(RuntimeContext, Msg)HarnessAgent.javainterrupt(RuntimeContext)/interrupt(RuntimeContext, Msg)delegates →delegateHow to test: Middlewares/tools can now write
agent.interrupt(ctx)without casting — it correctly targets the session identified by theRuntimeContext. The change is backward-compatible (default methods delegate to legacyinterrupt()for existing implementations).Closes #1988, Closes #1989
Checklist
mvn spotless:applyagentscope-core— all 300+ tests pass;agentscope-harness— 6 pre-existingJUnit Failed to close extension contexterrors unrelated to this change)