Skip to content

fix(training-agent): emit completion webhooks on framework dispatch - #2868

Merged
bokelley merged 1 commit into
mainfrom
bokelley/issue-2843
Apr 22, 2026
Merged

bokelley merged 1 commit into
mainfrom
bokelley/issue-2843

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

  • Fixes three webhook_emission storyboard invariants that fail under TRAINING_AGENT_USE_FRAMEWORK=1: payload/idempotency_key presence, retry dedupe, and RFC 9421 signature verification (webhook_emission storyboard: 9421 signature + retry dedupe + payload shape failing (framework) #2843).
  • Framework dispatch's adapt() wrapper called the handler but never emitted the completion webhook when the buyer supplied push_notification_config.url. Legacy dispatch did this inline in task-handlers.ts.
  • Extracts emission into maybeEmitCompletionWebhook in webhooks.ts and calls it from both paths so framework and legacy emit byte-identical envelopes. adapt() now takes the tool name so the shared helper can look up TOOL_TO_TASK_TYPE.

Results

  • webhook_emission storyboard (framework): 4P/3F → 7P/0F
  • Framework clean count: 26/56 → 27/56 storyboards
  • Legacy path unchanged (45/56 clean before and after)
  • Unit tests: 631/631 passing locally; typecheck clean
  • Expert review (code-reviewer, ad-tech-protocol-expert) confirmed parity, no double-emit risk, no regressions

Test plan

  • webhook_emission passes under TRAINING_AGENT_USE_FRAMEWORK=1
  • webhook_emission still passes on legacy dispatch
  • Framework full run shows +1 clean, no regressions
  • npm run typecheck clean
  • npm run test:unit clean (631 passed)

Follow-up

Pre-existing spec-compliance bug surfaced during review but scoped out of this fix: the webhook envelope emits protocol: 'mcp' (a transport value) where core/mcp-webhook-payload.json $refs enums/adcp-protocol.json (domain values: media-buy, signals, governance, etc.). Legacy dispatch has always had this. Worth a separate issue if the schema validator starts enforcing it.

🤖 Generated with Claude Code

…loses #2843)

Framework dispatch's `adapt()` wrapper called the handler but never fired a
completion webhook when the buyer supplied `push_notification_config.url`,
breaking three `webhook_emission` storyboard invariants under
`TRAINING_AGENT_USE_FRAMEWORK=1`: payload/idempotency_key presence, retry
dedupe, and RFC 9421 signature verification. Legacy dispatch emitted inline.

Extract emission into `maybeEmitCompletionWebhook` in `webhooks.ts` and
call it from both paths so framework and legacy emit byte-identical
envelopes. `adapt()` now takes the tool name so the shared helper can
look up `TOOL_TO_TASK_TYPE`.

- webhook_emission storyboard: 4P/3F → 7P/0F under framework
- framework clean count: 26/56 → 27/56 storyboards
- legacy path unchanged (45/56 on both before and after)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant