fix(dataplane): make the self-hosted environment worker path usable - #2818
fix(dataplane): make the self-hosted environment worker path usable#2818vipzj wants to merge 2 commits into
Conversation
EnvironmentKeyAuthFilter calls ControlPlaneClient.verifyEnvironmentKey from
the reactive security filter chain (reactor-http-epoll thread). The WebClient
chain inside ends with .block(), which Reactor rejects on NonBlocking threads,
so verification always failed and every self-hosted environment worker request
was rejected with 401:
verifyEnvironmentKey failed for env_xxx: block()/blockFirst()/blockLast()
are blocking, which is not supported in thread reactor-http-epoll-4
Run the blocking verification on a small dedicated thread pool instead.
SelfHostedWorkerController and WorkerEnvironmentController wrap blocking work
(session resolve via ControlPlaneClient, work queue ops) in Mono.fromCallable
without subscribeOn, so the callable runs on the subscribing parallel/event-loop
thread and fails with:
resolveSession failed for sess_xxx: block()/blockFirst()/blockLast()
are blocking, which is not supported in thread parallel-1
The pending-tools endpoint returned 502 and work/poll failed intermittently,
which made the self-hosted hands worker unusable. Add
.subscribeOn(Schedulers.boundedElastic()) like the other data-plane
controllers (DataSessionApiController) already do.
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
CLA Not Signed The Contributor License Agreement (CLA) check is currently pending on this PR ( @vipzj please sign the CLA via the CLA assistant badge in the comment above, or visit https://cla-assistant.io/agentscope-ai/agentscope-java. Once signed, the Automated check by github-manager-bot |
Problem
The self-hosted environment (type
self_hosted) hands execution to an externalHandsWorkerMainworker, but on currentmainthe whole worker path is broken — every worker API call fails before doing any work:EnvironmentKeyAuthFiltercallsControlPlaneClient.verifyEnvironmentKeyfrom the reactive security filter chain (areactor-http-epollthread). The WebClient call inside ends with.block(), which Reactor rejects onNonBlockingthreads:Verification therefore always returns
falseand the filter never sets theenv:<id>authentication, sopending-tools/tool-results/work/pollall answer 401.SelfHostedWorkerControllerandWorkerEnvironmentControllerwrap blocking work (session resolve throughControlPlaneClient, work-queue ops) inMono.fromCallablewithoutsubscribeOn, so the callable runs on the subscribingparallel-*thread:GET /api/environments/{id}/sessions/{sid}/pending-toolsreturns 502 andwork/pollfails intermittently.Fix
ControlPlaneClient: run the blocking key verification on a small dedicated daemon thread pool instead of the event-loop thread..subscribeOn(Schedulers.boundedElastic()), matching what the other data-plane controllers (DataSessionApiController) already do — the class javadoc ofControlPlaneClientexplicitly requires callers to schedule off the event loop.Verification
Deployed the data plane with these patches and verified the full flow end to end with a real
HandsWorkerMainworker:pending-tools/tool-results/work/pollreturn 200 with valid environment keys (X-Builder-Environment-Key);self_hostedenvironment suspends withsession.requires_action (tool_suspended)as designed;execute+write_filelocally, posts results, and the suspended turn resumes and produces the finalagent.message.mvn spotless:checkandmvn -pl agentscope-service/service-dataplane packagepass.