Context
PR #560 echoed request context onto MCP structuredContent and A2A DataPart for the synchronous AdcpError raise path. Background-task failures route through a different code path that #560 does NOT touch.
The path
src/adcp/decisioning/dispatch.py:1275-1292 — TaskHandoff background fn raises and is caught by:
except AdcpError as exc:
await registry.fail(task_id, exc.to_wire())
return
except Exception as exc:
# ... wraps to AdcpError(INTERNAL_ERROR)
await registry.fail(task_id, wrapped.to_wire())
exc.to_wire() produces the structured envelope that lands in the task registry. When a buyer polls the task status (or the registry pushes via webhook), they receive this envelope — without the request context echoed.
The fix shape
The registry-fail call site has access to the original request params (the same params TaskHandoff was invoked with). Threading them through and applying inject_context on the wire dict before registry.fail mirrors PR #560.
Likely API:
registry.fail(task_id, wire_envelope) → registry.fail(task_id, wire_envelope, request_params=None)
- Or build the echoed envelope at the dispatch site and pass it pre-merged.
Acceptance
tests/test_handoff_registry.py (or similar) adds a test where the background fn raises an AdcpError, the request had a context field, and the registry-stored wire envelope carries that context.
- Symmetric test for the success path (TaskHandoff completes normally — does the success registry payload echo context today? Verify before fixing.)
Context
PR #560 echoed request
contextonto MCPstructuredContentand A2A DataPart for the synchronous AdcpError raise path. Background-task failures route through a different code path that #560 does NOT touch.The path
src/adcp/decisioning/dispatch.py:1275-1292—TaskHandoffbackground fn raises and is caught by:exc.to_wire()produces the structured envelope that lands in the task registry. When a buyer polls the task status (or the registry pushes via webhook), they receive this envelope — without the requestcontextechoed.The fix shape
The registry-fail call site has access to the original request params (the same params
TaskHandoffwas invoked with). Threading them through and applyinginject_contexton the wire dict beforeregistry.failmirrors PR #560.Likely API:
registry.fail(task_id, wire_envelope)→registry.fail(task_id, wire_envelope, request_params=None)Acceptance
tests/test_handoff_registry.py(or similar) adds a test where the background fn raises an AdcpError, the request had acontextfield, and the registry-stored wire envelope carries thatcontext.