Skip to content

fix(core): promote interrupt(RuntimeContext) to Agent interface to fix slot-mismatch silent failure#1990

Open
Buktal wants to merge 1 commit into
agentscope-ai:mainfrom
Buktal:fix/interrupt-slot-mismatch-1988
Open

fix(core): promote interrupt(RuntimeContext) to Agent interface to fix slot-mismatch silent failure#1990
Buktal wants to merge 1 commit into
agentscope-ai:mainfrom
Buktal:fix/interrupt-slot-mismatch-1988

Conversation

@Buktal

@Buktal Buktal commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.0.0-SNAPSHOT

Description

Problem: 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. Middlewares holding both Agent agent and RuntimeContext ctx (e.g. onModelCall, onReasoning) were forced to cast ((ReActAgent) agent).interrupt(ctx), as seen in SubAgentTool.java:200-229.

Solution: Add interrupt(RuntimeContext) and interrupt(RuntimeContext, Msg) as default methods on the Agent interface. ReActAgent already had these methods with real per-session trigger logic — now they properly @Override the interface methods. HarnessAgent gains the missing delegates so the methods work through the harness wrapper.

Changes:

File What changed
Agent.java New default interrupt(RuntimeContext) / interrupt(RuntimeContext, Msg); mark old methods @Deprecated(forRemoval=true)
AgentBase.java Upgrade Javadoc on all legacy interrupt methods, add forRemoval=true
ReActAgent.java Add @Override to existing interrupt(RuntimeContext) / interrupt(RuntimeContext, Msg)
HarnessAgent.java Add missing interrupt(RuntimeContext) / interrupt(RuntimeContext, Msg) delegates → delegate

How to test: Middlewares/tools can now write agent.interrupt(ctx) without casting — it correctly targets the session identified by the RuntimeContext. The change is backward-compatible (default methods delegate to legacy interrupt() for existing implementations).

Closes #1988, Closes #1989

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (agentscope-core — all 300+ tests pass; agentscope-harness — 6 pre-existing JUnit Failed to close extension context errors unrelated to this change)
  • Javadoc comments are complete and follow project conventions
  • Code is ready for review

…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
@Buktal Buktal requested a review from a team July 2, 2026 09:33
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../src/main/java/io/agentscope/core/agent/Agent.java 0.00% 4 Missing ⚠️
...java/io/agentscope/harness/agent/HarnessAgent.java 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@AgentScopeJavaBot AgentScopeJavaBot added enhancement New feature or request area/core/agent Agent runtime, pipeline, hooks, plan labels Jul 11, 2026

@AgentScopeJavaBot AgentScopeJavaBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

Promotes interrupt(RuntimeContext) to Agent interface to fix slot-mismatch silent failure. The interrupt method signature now includes RuntimeContext for proper session key resolution. Important interface-level change ensuring interrupts target the correct session slot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core/agent Agent runtime, pipeline, hooks, plan enhancement New feature or request

Projects

None yet

2 participants