Skip to content

fix(harness): propagate userId through wakeup dispatch#2001

Merged
chickenlj merged 1 commit into
agentscope-ai:mainfrom
hansiweicn-debug:fix/wakeup-propagate-userid
Jul 6, 2026
Merged

fix(harness): propagate userId through wakeup dispatch#2001
chickenlj merged 1 commit into
agentscope-ai:mainfrom
hansiweicn-debug:fix/wakeup-propagate-userid

Conversation

@hansiweicn-debug

Copy link
Copy Markdown
Contributor

Resolves #2000.

Summary

WakeupDispatcher.dispatch discarded the userId that enqueueWakeup had already stored in the wakeup queue. In runtimes isolating agent state by (userId, sessionId), the wakeup round built a RuntimeContext without a userId, loaded state from an anonymous slot, lost the original conversation, and the provider returned 400 "No user query found in messages." This forwards the userId end-to-end.

Changes

  • WakeupTarget: add default runWakeup(userId, sessionId) delegating to the legacy overload; mark runWakeup(sessionId) @Deprecated.
  • WakeupDispatcher.dispatch: read userId from the wakeup payload and forward it to the target.
  • HarnessGateway: override the new overload; set rtc.userId(...) when non-blank (matching runStream). Blank/null userId keeps the legacy anonymous behaviour — no regression for single-tenant runtimes.

Backward compatibility

The single-arg runWakeup(String) stays on the interface (@Deprecated, with a default that delegates to it), so existing WakeupTarget implementations — including external ones — compile and behave as before. The dispatcher now calls the user-id-aware overload, which HarnessGateway overrides; any implementation that does not override it falls back via the default.

Tests

  • Added WakeupDispatcherTest#wakeupDispatch_propagatesUserId: enqueues a wakeup with a userId and asserts the target receives it.
  • All existing WakeupDispatcherTest cases pass unchanged (StubTarget unchanged).
mvn test -pl agentscope-harness -Dtest=WakeupDispatcherTest
# Tests run: 5, Failures: 0, Errors: 0, Skipped: 0

HarnessGateway.runWakeup's userId->rtc assignment mirrors the production-proven runStream pattern (if (!isBlank) rtcBuilder.userId(...)); kept the PR focused without a dedicated gateway integration test, but happy to add one if reviewers want end-to-end rtc coverage. Spotless applied; only the three intended files are in the diff.

WakeupDispatcher.dispatch read only sessionId/agentId from the wakeup
payload and invoked runWakeup(String), discarding the userId that
enqueueWakeup had already stored in the queue. In runtimes that isolate
agent state by (userId, sessionId), the wakeup-driven round then built a
RuntimeContext without a userId, loaded state from an anonymous slot,
and lost the original conversation -- the model received no user message
and the provider rejected the request with 400 "No user query found in
messages."

- WakeupTarget: add default runWakeup(userId, sessionId) delegating to
  the legacy overload; mark runWakeup(sessionId) @deprecated.
- WakeupDispatcher.dispatch: read userId from the payload and forward it.
- HarnessGateway: override the new overload and set rtc.userId when
  non-blank (matching runStream), so the wakeup round loads the same
  (userId, sessionId) slot as the original run. Blank/null userId keeps
  the legacy anonymous behaviour -- no regression for single-tenant
  runtimes.

Backward compatible: existing WakeupTarget implementers compile and run
unchanged. Adds a WakeupDispatcherTest case asserting the userId is
forwarded to the target.
@hansiweicn-debug hansiweicn-debug requested a review from a team July 3, 2026 09:16
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...entscope/harness/agent/gateway/HarnessGateway.java 0.00% 5 Missing ⚠️
...tscope/harness/agent/gateway/WakeupDispatcher.java 75.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jujn jujn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@chickenlj chickenlj merged commit db4c254 into agentscope-ai:main Jul 6, 2026
5 of 6 checks passed
zouyx pushed a commit to zouyx/agentscope-java that referenced this pull request Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: WakeupDispatcher drops userId, causing wakeup rounds to lose the original conversation in multi-tenant runtimes

3 participants