Files
Jordan Ritter d0f5fd772f fix(showcase): propagate x-aimock-context across AG-UI SDK pooled-thread hop in spring-ai
The spring-ai integration stashed inbound x-* headers in an
InheritableThreadLocal (AimockHeaderContext) on the Tomcat request thread,
but the AG-UI Java SDK's LocalAgent.runAgent dispatches the LLM call via
CompletableFuture.runAsync onto a pre-existing ForkJoinPool.commonPool()
worker. InheritableThreadLocal only copies the parent value at thread
creation, so a reused pooled worker snapshots an empty/stale map and the
outbound RestClient/WebClient interceptor drops x-aimock-context. aimock
strict mode then 503s, yielding an empty assistant message and a
conversation-error on d5/d6 agentic pills.

Add explicit propagation: AimockHeaderContext.capture()/runWith() snapshot
the headers on the request thread and re-establish them on whatever worker
thread runs the agent. A new PropagatingLocalAgent base class wires these
around the runAsync boundary; all six LocalAgent subclasses now extend it.
This mirrors the AsyncLocalStorage shim used by the TypeScript integrations
(e.g. mastra's _header_forwarding.ts).
2026-06-06 01:58:15 -07:00
..