feat(agent-dispatch): accept webhook run metadata - #4369
Conversation
|
Someone is attempting to deploy a commit to the Latitude Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughWebhook 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. ChangesWebhook metadata acknowledgement
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
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
dev-docs/agent-dispatch.mddocs/agent-dispatch/webhooks.mdxpackages/platform/agent-dispatch/package.jsonpackages/platform/agent-dispatch/src/adapters/webhook-adapter.test.tspackages/platform/agent-dispatch/src/adapters/webhook-adapter.ts
There was a problem hiding this comment.
💡 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".
|
recheck |
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
|
@ChenCJ-io sign the cla please ☝🏼 |
geclos
left a comment
There was a problem hiding this comment.
@ChenCJ-io address both codex and coderabbit comments please
bb08242 to
3770d6a
Compare
|
Addressed the two automated review comments and pushed the fixes to
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/platform/agent-dispatch/src/adapters/webhook-adapter.test.ts (1)
58-80: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd an output-trimming assertion.
The test uses identifiers without whitespace. It does not verify that returned
externalAgentIdandexternalRunIdare 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
📒 Files selected for processing (2)
packages/platform/agent-dispatch/src/adapters/webhook-adapter.test.tspackages/platform/agent-dispatch/src/adapters/webhook-adapter.ts
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
|
Addressed the remaining CodeRabbit test-coverage nitpick in |
|
@geclos CLA is now signed and passing. Both requested review fixes and the remaining CodeRabbit test nitpick are addressed in |
|
@geclos Small CI follow-up: |
What does this PR do?
Accepts optional JSON metadata returned by successful agent dispatch webhooks:
externalAgentIdexternalRunIddeepLinkUrlEach field is validated independently. IDs are trimmed and must be non-empty;
deepLinkUrlmust 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 checkpnpm --filter @platform/agent-dispatch typecheckpnpm --filter @platform/agent-dispatch test(5 files, 21 tests)pnpm check(88 tasks)pnpm typecheck(92 tasks)pnpm knipgit diff --checkA full
pnpm testrun completed 80 of 87 workspace tasks.@app/workerscould not load the localchdb_node.nodenative binding, and two PGlite setup hooks timed out. Building the required binding withpnpm --filter @platform/testkit chdb:buildwas attempted, but the GitHub release asset remained at 0 bytes in this environment.Checklist
Summary by CodeRabbit
New Features
Documentation