You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am investigating the Reactor subscriber-context loss in AsyncToolMiddleware on current main (6a05680). I will first add a deterministic regression covering AgentEventEmitter and caller context propagation across the detached subscription, then validate a minimal fix. I will keep the separate post-timeout event-routing semantics out of scope unless the regression demonstrates they must change. This work uses AI assistance; any proposed PR will remain draft pending independent review.
Root Cause:AsyncToolMiddleware (agentscope-harness/.../middleware/AsyncToolMiddleware.java:99-179) subscribes to next.apply(input) inside a Flux.create sink without deferContextual/contextWrite, so the Reactor subscriber Context is not propagated across that boundary. AgentEventEmitter.fromContext(ctxView) (the emitter stored under agentscope.agent.event.emitter, see AgentEventEmitter.java:45) therefore finds nothing, and AgentSpawnTool cannot stream sub-agent events to the parent.
Second symptom is also real: after the async timeout path, only ToolResultTextDeltaEvent is forwarded from the background buffer to the inbox (AsyncToolMiddleware.java:237-289) and the sink is completed (:234), so a ToolCallResultEvent emitted later inside next.apply never reaches the caller's stream — matching the "only received if the agent stream happens to still be running" observation.
Impact: sub-agent event streaming and background tool results are lost whenever AsyncToolMiddleware is enabled; middleware chain construction (MiddlewareChain.java:46-62) does not restore context across next.apply either.
Severity: high (breaks observable event flow for harness sub-agents).
Note: community PR #3299 ("fix(harness): preserve subscriber context in async tool execution") targets exactly this and is still open, not yet merged into main. To avoid duplicate work, we should review/merge #3299 rather than generate a competing fix; a regression test that pins the AgentEventEmitter context propagation through the async path would strengthen it.
Activity
breezeFur commentedon Sep 26, 2026
I am investigating the Reactor subscriber-context loss in AsyncToolMiddleware on current main (6a05680). I will first add a deterministic regression covering AgentEventEmitter and caller context propagation across the detached subscription, then validate a minimal fix. I will keep the separate post-timeout event-routing semantics out of scope unless the regression demonstrates they must change. This work uses AI assistance; any proposed PR will remain draft pending independent review.
oss-maintainer commentedon Sep 27, 2026
Issue Evaluation
Category:
bug| Status: Confirmed on currentmainVerified against the codebase:
AsyncToolMiddleware(agentscope-harness/.../middleware/AsyncToolMiddleware.java:99-179) subscribes tonext.apply(input)inside aFlux.createsink withoutdeferContextual/contextWrite, so the Reactor subscriber Context is not propagated across that boundary.AgentEventEmitter.fromContext(ctxView)(the emitter stored underagentscope.agent.event.emitter, seeAgentEventEmitter.java:45) therefore finds nothing, andAgentSpawnToolcannot stream sub-agent events to the parent.ToolResultTextDeltaEventis forwarded from the background buffer to the inbox (AsyncToolMiddleware.java:237-289) and the sink is completed (:234), so aToolCallResultEventemitted later insidenext.applynever reaches the caller's stream — matching the "only received if the agent stream happens to still be running" observation.AsyncToolMiddlewareis enabled; middleware chain construction (MiddlewareChain.java:46-62) does not restore context acrossnext.applyeither.Note: community PR #3299 ("fix(harness): preserve subscriber context in async tool execution") targets exactly this and is still open, not yet merged into
main. To avoid duplicate work, we should review/merge #3299 rather than generate a competing fix; a regression test that pins theAgentEventEmittercontext propagation through the async path would strengthen it.Automated evaluation by github-manager-bot