Skip to content

fix(harness): add per-session interrupt methods to HarnessAgent - #2600

Open
xy-ygz wants to merge 1 commit into
agentscope-ai:mainfrom
xy-ygz:fix/harness-agent-interrupt-session
Open

fix(harness): add per-session interrupt methods to HarnessAgent#2600
xy-ygz wants to merge 1 commit into
agentscope-ai:mainfrom
xy-ygz:fix/harness-agent-interrupt-session

Conversation

@xy-ygz

@xy-ygz xy-ygz commented Aug 7, 2026

Copy link
Copy Markdown

HarnessAgent only forwarded no-arg interrupt(), which routed to ReActAgent's deprecated default session. Add RuntimeContext and (userId, sessionId) overloads aligned with clearContext().

Fixes #2509

AgentScope-Java Version

2.0.1-SNAPSHOT (main)

Description

Fixes #2509.

Background: ReActAgent already supports per-session interrupt via interrupt(RuntimeContext) and interrupt(String userId, String sessionId), but HarnessAgent only forwarded the deprecated no-arg interrupt() / interrupt(Msg), which always routed to the default session slot. In multi-tenant deployments, callers could not interrupt a specific (userId, sessionId) session through HarnessAgent.

Changes:

  • Add four session-scoped overloads on HarnessAgent, delegating to the internal ReActAgent:
    • interrupt(RuntimeContext ctx)
    • interrupt(RuntimeContext ctx, Msg msg)
    • interrupt(String userId, String sessionId)
    • interrupt(String userId, String sessionId, Msg msg)
  • Follows the same pattern as existing methods like clearContext().
  • Add regression tests in HarnessAgentTest verifying session isolation.

How to test:

mvn -pl agentscope-harness spotless:apply
mvn -pl agentscope-harness -am test \
  -Dtest=HarnessAgentTest#interruptWithUserIdAndSessionIdTargetsOnlyThatSession,HarnessAgentTest#interruptWithRuntimeContextDelegatesToReActAgent \
  -Dsurefire.failIfNoSpecifiedTests=false

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test — targeted HarnessAgentTest interrupt tests: 2 passed, 0 failures)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (not needed; no user-facing API doc change beyond new public methods)
  • Code is ready for review

HarnessAgent only forwarded no-arg interrupt(), which routed to
ReActAgent's deprecated default session. Add RuntimeContext and
(userId, sessionId) overloads aligned with clearContext().

Fixes agentscope-ai#2509
@CLAassistant

CLAassistant commented Aug 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@xy-ygz xy-ygz closed this Aug 7, 2026
@xy-ygz
xy-ygz deleted the fix/harness-agent-interrupt-session branch August 7, 2026 10:36
@xy-ygz
xy-ygz restored the fix/harness-agent-interrupt-session branch August 7, 2026 10:47
@xy-ygz xy-ygz reopened this Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@oss-maintainer oss-maintainer 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.

Summary

This PR modifies 2 files with 121 lines of diff.

Observations

  • Files changed: 2
  • Test coverage: ✅ Tests included
  • CLA: ✅ Signed

Suggestions

  • Please ensure all public API changes are backward compatible
  • Consider adding unit tests for new logic paths

Automated review by github-manager-bot

@AgentScopeJavaBot AgentScopeJavaBot added bug Something isn't working area/harness agentscope-harness (test/runtime support) labels Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/harness agentscope-harness (test/runtime support) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: The interrupt() method of HarnessAgent does not support passing userId and sessionId

4 participants