Skip to content

feat(agent-dispatch): accept webhook run metadata - #4369

Merged
geclos merged 4 commits into
latitude-dev:developmentfrom
ChenCJ-io:feat/webhook-dispatch-ack-metadata
Aug 12, 2026
Merged

feat(agent-dispatch): accept webhook run metadata#4369
geclos merged 4 commits into
latitude-dev:developmentfrom
ChenCJ-io:feat/webhook-dispatch-ack-metadata

Conversation

@ChenCJ-io

@ChenCJ-io ChenCJ-io commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Accepts optional JSON metadata returned by successful agent dispatch webhooks:

  • externalAgentId
  • externalRunId
  • deepLinkUrl

Each field is validated independently. IDs are trimmed and must be non-empty; deepLinkUrl must be an absolute HTTP(S) URL. Empty, non-JSON, malformed, or partially invalid response bodies do not turn a successful dispatch into a failure. When no valid link is returned, Latitude continues using the configured webhook URL.

This lets custom receivers correlate Latitude dispatch records with the external agent run they start and link operators directly to that run. The response contract is documented in the public webhook guide and the agent dispatch developer documentation.

Related issue (if applicable)

Closes #4368

How was this tested?

  • pnpm --filter @platform/agent-dispatch check
  • pnpm --filter @platform/agent-dispatch typecheck
  • pnpm --filter @platform/agent-dispatch test (5 files, 21 tests)
  • pnpm check (88 tasks)
  • pnpm typecheck (92 tasks)
  • pnpm knip
  • git diff --check

A full pnpm test run completed 80 of 87 workspace tasks. @app/workers could not load the local chdb_node.node native binding, and two PGlite setup hooks timed out. Building the required binding with pnpm --filter @platform/testkit chdb:build was attempted, but the GitHub release asset remained at 0 bytes in this environment.

Checklist

  • Lint, type-checking, and tests pass locally
  • PR title follows Conventional Commits
  • I have signed the CLA

Summary by CodeRabbit

  • New Features

    • Webhook responses can include external agent and run identifiers.
    • Valid deep links are recorded with dispatch history; the configured webhook URL is used when no valid link is provided.
    • Missing, empty, malformed, oversized, or partially invalid acknowledgement responses remain successful.
    • Webhook acknowledgement processing handles slow or interrupted responses without blocking indefinitely.
  • Documentation

    • Added guidance on supported acknowledgement fields, validation, recording, fallback behavior, and response handling.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Latitude Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0d650fe4-b85e-4077-942a-6ec3931bdd68

📥 Commits

Reviewing files that changed from the base of the PR and between 3770d6a and 1806ddf.

📒 Files selected for processing (1)
  • packages/platform/agent-dispatch/src/adapters/webhook-adapter.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/platform/agent-dispatch/src/adapters/webhook-adapter.test.ts

📝 Walkthrough

Walkthrough

Webhook dispatch now parses successful JSON acknowledgements for optional external agent and run metadata. It validates identifiers and deep links, tolerates invalid response bodies, and uses the configured webhook URL as the fallback link.

Changes

Webhook metadata acknowledgement

Layer / File(s) Summary
Acknowledgement parsing and dispatch integration
packages/platform/agent-dispatch/package.json, packages/platform/agent-dispatch/src/adapters/webhook-adapter.ts, dev-docs/agent-dispatch.md, docs/agent-dispatch/webhooks.mdx
Added Zod validation and bounded acknowledgement reading. Valid metadata is returned through the dispatch ledger. Invalid, empty, oversized, or interrupted responses remain accepted with the configured webhook URL as the fallback link. Documentation describes the response contract.
Acknowledgement response test coverage
packages/platform/agent-dispatch/src/adapters/webhook-adapter.test.ts
Added shared dispatch setup and coverage for signatures, valid and partially invalid metadata, malformed responses, oversized bodies, and never-ending response streams.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant WebhookAdapter
  participant WebhookReceiver
  participant DispatchLedger
  WebhookAdapter->>WebhookReceiver: Send dispatch webhook
  WebhookReceiver-->>WebhookAdapter: Return acknowledgement body
  WebhookAdapter->>DispatchLedger: Store valid metadata or fallback URL
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: accepting webhook run metadata.
Linked Issues check ✅ Passed The implementation, documentation, dependency, and tests address all coding objectives in issue #4368.
Out of Scope Changes check ✅ Passed All changes support webhook metadata handling, validation, documentation, dependency setup, or related test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/platform/agent-dispatch/src/adapters/webhook-adapter.ts`:
- Around line 88-90: Update the successful acknowledgement response handling
around response.json() to enforce both a maximum response-body byte limit and a
read deadline. When either limit is exceeded, discard the response metadata and
return the existing accepted fallback response, while preserving normal parsing
for bounded bodies.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ab860819-5970-4481-95e0-3eecc04d48ac

📥 Commits

Reviewing files that changed from the base of the PR and between 03cce03 and bb08242.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • dev-docs/agent-dispatch.md
  • docs/agent-dispatch/webhooks.mdx
  • packages/platform/agent-dispatch/package.json
  • packages/platform/agent-dispatch/src/adapters/webhook-adapter.test.ts
  • packages/platform/agent-dispatch/src/adapters/webhook-adapter.ts

Comment thread packages/platform/agent-dispatch/src/adapters/webhook-adapter.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb0824276b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/platform/agent-dispatch/src/adapters/webhook-adapter.ts Outdated
@geclos

geclos commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

recheck

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@geclos

geclos commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

@ChenCJ-io sign the cla please ☝🏼

geclos
geclos previously approved these changes Aug 10, 2026

@geclos geclos left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChenCJ-io address both codex and coderabbit comments please

@ChenCJ-io
ChenCJ-io force-pushed the feat/webhook-dispatch-ack-metadata branch from bb08242 to 3770d6a Compare August 10, 2026 09:00
@ChenCJ-io

ChenCJ-io commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the two automated review comments and pushed the fixes to feat/webhook-dispatch-ack-metadata (latest 3770d6a796).

  • Invalid or unsafe deepLinkUrl values now fail closed to the configured webhook URL instead of throwing (a791cc2c68).
  • Successful acknowledgement reads are bounded to 64 KiB with a 1-second deadline; oversized, timed-out, or malformed bodies preserve the accepted fallback (3770d6a796).

Validation completed locally: agent-dispatch tests (25 passing), package Biome check, package typecheck, workspace typecheck (92/92 tasks), db-clickhouse tests (614 passing), workers tests (131 passing), and git diff --check. A parallel full pnpm test also exposed unrelated local PGlite initialization timeouts; the affected packages pass independently.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/platform/agent-dispatch/src/adapters/webhook-adapter.test.ts (1)

58-80: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add an output-trimming assertion.

The test uses identifiers without whitespace. It does not verify that returned externalAgentId and externalRunId are trimmed. Send padded identifiers and assert the returned values have no leading or trailing whitespace.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/platform/agent-dispatch/src/adapters/webhook-adapter.test.ts` around
lines 58 - 80, The successful JSON acknowledgement test around dispatchWebhook
should use whitespace-padded externalAgentId and externalRunId values in the
mocked response, while asserting the resolved metadata contains trimmed
identifiers without leading or trailing whitespace; keep the deepLinkUrl and
accepted status assertions unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/platform/agent-dispatch/src/adapters/webhook-adapter.test.ts`:
- Around line 58-80: The successful JSON acknowledgement test around
dispatchWebhook should use whitespace-padded externalAgentId and externalRunId
values in the mocked response, while asserting the resolved metadata contains
trimmed identifiers without leading or trailing whitespace; keep the deepLinkUrl
and accepted status assertions unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6733c241-aa03-4472-8b3c-85802504a7d4

📥 Commits

Reviewing files that changed from the base of the PR and between bb08242 and 3770d6a.

📒 Files selected for processing (2)
  • packages/platform/agent-dispatch/src/adapters/webhook-adapter.test.ts
  • packages/platform/agent-dispatch/src/adapters/webhook-adapter.ts

@ChenCJ-io

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@ChenCJ-io

Copy link
Copy Markdown
Contributor Author

recheck

github-actions Bot added a commit that referenced this pull request Aug 10, 2026
@ChenCJ-io

Copy link
Copy Markdown
Contributor Author

Addressed the remaining CodeRabbit test-coverage nitpick in 1806ddf437: the successful acknowledgement test now sends whitespace-padded identifiers and asserts the returned metadata is trimmed. Verified agent-dispatch tests (25 passing), package Biome check, package typecheck, and git diff --check.

@ChenCJ-io

Copy link
Copy Markdown
Contributor Author

@geclos CLA is now signed and passing. Both requested review fixes and the remaining CodeRabbit test nitpick are addressed in 1806ddf437; CodeRabbit, CLA Assistant, and Socket checks are passing. The previous approval became stale after the required force-push, so could you please re-review the latest commit and re-approve? Vercel still reports a Latitude-team deployment authorization requirement.

@ChenCJ-io

Copy link
Copy Markdown
Contributor Author

@geclos Small CI follow-up: test-integration failed only because Vitest could not terminate a fork for the unrelated @platform/db-clickhouse session-cost-factors.test.ts; 613/614 tests passed and there was no assertion failure. The same package passed locally with 614/614 tests. I do not have repository admin rights to rerun the failed job—could you rerun it when reviewing? Thanks.

@geclos
geclos merged commit a381391 into latitude-dev:development Aug 12, 2026
15 of 17 checks passed
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Latitude LLM Roadmap Aug 12, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Allow agent dispatch webhooks to return external run metadata

3 participants