Skip to content

feat: TaskHandoff registry.fail path should echo request context (PR #560 follow-up) #563

@bokelley

Description

@bokelley

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-1292TaskHandoff 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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingclaude-triagedno-triageSkip the Claude triage bot — human or designated agent will handle this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions