Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
TL;DR — Routes tool approval requests from delegated sub-agents through the durable workflow hook system (WDK) instead of the in-memory pub/sub bus, and fixes a re-delegation loop where approving a delegated tool caused the parent to re-send the original user message instead of continuing with the tool result. Key changes
Summary | 9 files | 4 commits | base: Parent-side detection of delegated approval artifacts
Post-approval continuation prompt to prevent re-delegation loop
The flag is set after each approval round in
Delegated approval forwarding through A2A delegation metadata
The
|
There was a problem hiding this comment.
Solid approach — the artifact-based signaling pattern for durable delegated approvals is a clean replacement for the in-memory pub/sub, and the isPostApproval continuation prompt correctly breaks the re-delegation loop. Three issues to flag, one potentially breaking.
Claude Opus | 𝕏
agents-api/src/domains/run/workflow/steps/agentExecutionSteps.ts
Outdated
Show resolved
Hide resolved
Preview URLsUse these stable preview aliases for testing this PR:
These point to the same Vercel preview deployment as the bot comment, but they stay stable and easier to find. Raw Vercel deployment URLs
|
There was a problem hiding this comment.
PR Review Summary
(7) Total Issues | Risk: Medium
🟠⚠️ Major (3) 🟠⚠️
Inline Comments:
- 🟠 Major:
tool-wrapper.ts:231Unsafe type coercion of approval artifact fields without validation - 🟠 Major:
agentExecutionSteps.ts:555-576SSE streaming for delegated approvals lacks error handling - 🟠 Major:
agentExecution.ts:82-85Durable workflow hook awaits indefinitely without timeout
🟡 Minor (1) 🟡
Inline Comments:
- 🟡 Minor:
agentExecution.ts:82-86Improve logging for delegated approval debugging
🕐 Pending Recommendations (3)
From pullfrog's prior review (still applicable):
- 🟠
agentExecutionSteps.ts:123baseUrl now includes/run/agents— deviates from bare API root convention used elsewhere - 🟡
relationTools.ts:436Type casting delegationMeta to inject workflow metadata sidesteps type safety - 🟡
agentExecutionSteps.ts:507Continuation prompt dependency on conversation history needs documentation
🚫 REQUEST CHANGES
Summary: The artifact-based signaling pattern is a solid architectural choice for durable delegated approvals, and the isPostApproval continuation prompt correctly addresses the re-delegation loop. However, there are three major issues that should be addressed before merging:
-
Artifact validation — The
durable-approval-requiredartifact fields are used without validation, which could cause silent corruption or unhelpful runtime errors if a sub-agent returns malformed data. -
SSE error handling — The delegated approval SSE streaming block has no error handling. If writes fail, the workflow suspends awaiting approval but the client never receives the approval request UI — a particularly confusing failure mode.
-
Indefinite workflow suspension — Unlike the non-durable path (10-minute timeout), the durable workflow hook can suspend indefinitely. Consider either adding a timeout or documenting the expected cleanup strategy.
The pullfrog findings about baseUrl convention and type casting are worth addressing as follow-ups but are less critical.
Discarded (3)
| Location | Issue | Reason Discarded |
|---|---|---|
agentExecutionSteps.ts:155-167 |
Empty catch blocks in enhanceRelation | Pre-existing code not introduced by this PR |
tool-wrapper.ts:196 |
Nested artifact parsing without bounds | Low likelihood of malicious sub-agent responses in controlled environment |
agentExecutionSteps.ts:503 |
isPostApproval may not survive workflow replays | Workflow engine handles step replay correctly; flag is set consistently in workflow scope |
Reviewers (3)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
pr-review-errors |
4 | 0 | 0 | 0 | 2 | 0 | 2 |
pr-review-sre |
5 | 0 | 0 | 0 | 2 | 0 | 3 |
pr-review-standards |
0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Total | 9 | 0 | 0 | 0 | 4 | 0 | 5 |
Note: pr-review-standards found no issues — validated that baseUrl change is consistent with existing patterns in executionHandler.ts and data/agents.ts.
agents-api/src/domains/run/workflow/steps/agentExecutionSteps.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
PR Review Summary
(8) Total Issues | Risk: Medium | Review Scope: Delta (1 commit since last review)
This is a re-review scoped to changes in commit 5aea41ec7 ("fix: handle AI SDK stopWhen throw for durable approval detection").
🟠⚠️ Major (1) 🟠⚠️
Inline Comments:
- 🟠 Major:
agentExecutionSteps.ts:533-537Swallowing errors silently when pendingDurableApproval is set
🟡 Minor (1) 🟡
Inline Comments:
- 🟡 Minor:
generateTaskHandler.ts:585-588Catch block suppresses original error without logging
🕐 Pending Recommendations (6)
From prior automated review (claude):
- 🟠
tool-wrapper.ts:231Unsafe type coercion of approval artifact fields without validation - 🟠
agentExecutionSteps.ts:555-576SSE streaming for delegated approvals lacks error handling - 🟠
agentExecution.ts:82-85Durable workflow hook awaits indefinitely without timeout
From pullfrog's prior review:
- 🟠
agentExecutionSteps.ts:123baseUrl now includes/run/agents— deviates from bare API root convention - 🟡
relationTools.ts:436Type casting delegationMeta to inject workflow metadata sidesteps type safety - 🟡
agentExecutionSteps.ts:507Continuation prompt dependency on conversation history needs documentation
🚫 REQUEST CHANGES
Summary: The delta commit (5aea41ec7) correctly addresses the AI SDK stopWhen throw behavior by catching the error and extracting the pending approval state. However, silently discarding caught errors without logging creates a debugging blind spot. When errors are suppressed because pendingDurableApproval exists, engineers have no visibility into what actually failed. Add logging before suppressing these errors.
The 6 pending recommendations from the prior review remain unaddressed and should be considered alongside this delta feedback.
Discarded (1)
| Location | Issue | Reason Discarded |
|---|---|---|
agentExecutionSteps.ts:603-605 |
Error message lacks context | Low severity — the check is effectively dead code given the control flow (if catch re-throws, this line is unreachable) |
Reviewers (1)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
pr-review-errors |
3 | 0 | 0 | 0 | 2 | 0 | 1 |
| Total | 3 | 0 | 0 | 0 | 2 | 0 | 1 |
Note: Delta review — only dispatched error handling reviewer since the changes were focused on error/exception handling patterns.
agents-api/src/domains/run/workflow/steps/agentExecutionSteps.ts
Outdated
Show resolved
Hide resolved
5aea41e to
f6e94ae
Compare
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
This is a re-review following prior feedback from pullfrog and two automated claude reviews. All previously identified issues have been addressed.
✅ Issues Resolved Since Prior Reviews
| Prior Issue | Resolution |
|---|---|
🟠 Unsafe type coercion of approval artifact fields (tool-wrapper.ts:232-245) |
Fixed — Added validation with typeof checks and error logging before using delegatedToolCallId and delegatedToolName |
🟠 SSE streaming for delegated approvals lacks error handling (agentExecutionSteps.ts:583-611) |
Fixed — Wrapped SSE writes in try-catch with error logging and re-throw |
🟠 Durable workflow hook awaits indefinitely (agentExecution.ts:98-101) |
Documented — Comment explains the design decision and cleanup strategy via external job |
🟡 Improve logging for delegated approval debugging (agentExecution.ts:88-96) |
Fixed — Added logger.info with hookToolCallId, parentToolCallId, isDelegated, and workflowRunId |
🟡 Swallowing errors silently when pendingDurableApproval is set (agentExecutionSteps.ts:545-553) |
Fixed — Added logger.info capturing error message, error name, requestId, and currentSubAgentId |
🟡 Catch block suppresses original error without logging (generateTaskHandler.ts:591-598) |
Fixed — Added logger.info with toolCallId, toolName, and error message |
🟡 baseUrl convention deviation (agentExecutionSteps.ts:117-121) |
Documented — Comment explains the intentional deviation for durable mode |
🟡 Type casting delegationMeta (relationTools.ts:434-452) |
Accepted — The spread pattern is safe here since we're adding fields, not removing them |
🟡 Continuation prompt dependency on conversation history (agentExecutionSteps.ts:507-510) |
Documented — Comment explains the dependency on skipHistoryStorage fix |
Architecture Assessment
The artifact-based signaling pattern for durable delegated approvals is well-designed:
- Artifact flow — Sub-agents return
durable-approval-requiredartifacts that the parent'stool-wrapperdetects and propagates throughpendingDurableApproval - Re-delegation loop prevention —
isPostApprovalflag switches to continuation prompt after approval rounds - Delegation metadata forwarding —
durableWorkflowRunIdandapprovedToolCallsflow through A2A metadata - SSE event streaming — Delegated approvals stream the correct
toolCallIdfrom the sub-agent
⚠️ Operational Note
The durable workflow hook (toolApprovalHook.create()) suspends indefinitely by design. The comment at lines 98-101 documents that stale suspended workflows should be cleaned up by an external job querying workflow_executions with status='suspended'. Ensure this cleanup mechanism exists or is planned.
Missing Changeset
The changeset-bot flagged that this PR has no changeset. Since this adds support for tool approvals in delegated sub-agents running in durable execution mode, consider adding:
pnpm bump patch --pkg agents-api "Add support for tool approvals in delegated sub-agents during durable execution"✅ APPROVE
Summary: All prior review feedback has been addressed. The implementation is solid — artifact-based signaling cleanly replaces the in-memory pub/sub for durable delegated approvals, error handling is comprehensive with logging, and the isPostApproval continuation prompt correctly breaks the re-delegation loop. Ship it! 🚀
Reviewers (0)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
| Total | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Note: This re-review validated that all prior findings have been addressed. No new reviewers were dispatched since the diff showed only fixes to previously identified issues.
f6e94ae to
e8954e7
Compare
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
This is a re-review triggered by CI re-run. The code is unchanged from the prior APPROVE review — all previously identified issues remain resolved.
✅ Verified Fixes (from prior reviews)
| Prior Issue | Status |
|---|---|
| 🟠 Unsafe type coercion of approval artifact fields | ✅ Fixed — tool-wrapper.ts:232-245 has typeof validation |
| 🟠 SSE streaming lacks error handling | ✅ Fixed — agentExecutionSteps.ts:583-611 has try-catch with re-throw |
| 🟠 Durable workflow hook awaits indefinitely | ✅ Documented — agentExecution.ts:92-95 explains cleanup strategy |
| 🟡 Missing logging for delegated approval debugging | ✅ Fixed — agentExecution.ts:85-90 logs hook details |
| 🟡 Silent error swallowing when pendingDurableApproval set | ✅ Fixed — agentExecutionSteps.ts:545-553 logs caught errors |
| 🟡 Catch block suppresses original error | ✅ Fixed — generateTaskHandler.ts:591-598 logs error context |
| 🟡 baseUrl convention deviation | ✅ Documented — agentExecutionSteps.ts:117-121 explains intentional deviation |
| 🟡 Continuation prompt history dependency | ✅ Documented — agentExecutionSteps.ts:507-510 explains reliance on skipHistoryStorage |
Architecture Assessment
The artifact-based signaling pattern for durable delegated approvals is well-designed:
- Artifact flow — Sub-agents return
durable-approval-requiredartifacts that the parent'stool-wrapperdetects and propagates viapendingDurableApproval - Re-delegation loop prevention —
isPostApprovalflag switches to continuation prompt after approval rounds - Delegation metadata forwarding —
durableWorkflowRunIdandapprovedToolCallsflow through A2A metadata - SSE event streaming — Delegated approvals stream the correct
toolCallIdfrom the sub-agent
⚠️ CI Note
The "Auto Format" workflow failure is a CI infrastructure issue (pnpm setup step), not a code problem.
Missing Changeset
Consider adding a changeset for this feature:
pnpm bump patch --pkg agents-api "Add support for tool approvals in delegated sub-agents during durable execution"✅ APPROVE
Summary: All prior review feedback has been addressed. The implementation is solid — artifact-based signaling cleanly replaces the in-memory pub/sub for durable delegated approvals, error handling is comprehensive with logging, and the isPostApproval continuation prompt correctly breaks the re-delegation loop. Ship it! 🚀
Reviewers (0)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
| Total | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Note: Re-review — validated prior fixes are still present. No new reviewers dispatched.
When a delegated sub-agent requires tool approval in durable mode, the approval now flows through the workflow hook system instead of the in-memory pub/sub bus. The parent agent detects `durable-approval-required` artifacts from sub-agents, surfaces them as SSE approval events, and forwards the user's decision back via `delegatedToolApproval` context on re-execution. Adds `isPostApproval` flag to prevent the workflow loop from re-sending the original user message after approval. Includes validation of approval artifact fields, SSE error handling for delegated approval streaming, logging for suppressed errors in the durable approval catch path, and type-safe metadata construction for delegation.
e8954e7 to
edb0a26
Compare
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
This is a re-review following 4 prior automated reviews. This review validates that all previously identified issues have been addressed.
✅ Issues Resolved Since Prior Reviews
| Prior Issue | Resolution |
|---|---|
| 🟠 Unsafe type coercion of approval artifact fields | ✅ Fixed — tool-wrapper.ts:232-245 validates typeof before using delegatedToolCallId and delegatedToolName |
| 🟠 SSE streaming for delegated approvals lacks error handling | ✅ Fixed — agentExecutionSteps.ts:597-625 wraps SSE writes in try-catch with error logging and re-throw |
| 🟠 Durable workflow hook awaits indefinitely without timeout | ✅ Documented — agentExecution.ts:94-97 explains cleanup strategy via external job querying workflow_executions |
| 🟡 Missing logging for delegated approval debugging | ✅ Fixed — agentExecution.ts:87-92 logs hookToolCallId, parentToolCallId, isDelegated, and workflowRunId |
| 🟡 Silent error swallowing when pendingDurableApproval set | ✅ Fixed — agentExecutionSteps.ts:559-567 logs error message, error name, requestId, and currentSubAgentId |
| 🟡 Catch block suppresses original error without logging | ✅ Fixed — generateTaskHandler.ts:620-627 logs toolCallId, toolName, and error message |
| 🟡 baseUrl convention deviation | ✅ Documented — agentExecutionSteps.ts:123-128 explains the intentional deviation for durable mode |
| 🟡 Continuation prompt dependency on conversation history | ✅ Documented — tool-wrapper.ts:110-114 explains the dependency on skipHistoryStorage fix |
Architecture Assessment
The artifact-based signaling pattern for durable delegated approvals is well-designed:
- Artifact flow — Sub-agents return
durable-approval-requiredartifacts that the parent'stool-wrapperdetects viafindApprovalRequiredhelper and propagates throughpendingDurableApproval - Re-delegation loop prevention —
isPostApprovalflag inagentExecution.tsswitches to continuation prompt after approval rounds, preventing infinite delegation loops - Delegation metadata forwarding —
durableWorkflowRunIdandapproved_tool_callsflow through A2A metadata inrelationTools.ts - SSE event streaming — Delegated approvals stream the correct
toolCallIdfrom the sub-agent (not the parent's delegate tool call ID) - Type safety —
DelegatedApprovalContexttype properly captures the sub-agent's tool context
⚠️ Missing Changeset
Per the changeset-bot comment, this PR adds a user-facing feature but has no changeset. Consider adding:
pnpm bump patch --pkg agents-api "Add support for tool approvals in delegated sub-agents during durable execution"💡 APPROVE WITH SUGGESTIONS
Summary: All prior review feedback has been addressed. The implementation is solid — artifact-based signaling cleanly replaces the in-memory pub/sub for durable delegated approvals, error handling is comprehensive with logging, type validation prevents malformed artifacts from corrupting state, and the isPostApproval continuation prompt correctly breaks the re-delegation loop.
The only outstanding item is the missing changeset, which should be added before merging to ensure proper versioning.
Reviewers (0)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
| Total | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Note: This re-review validated that all prior findings have been addressed. No new reviewers were dispatched since the code showed only the final implementation with all fixes applied.
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low | Review Scope: Delta
This is a re-review scoped to the delta since the last automated review (ad195a073 → 6defd54af).
Delta Analysis
The delta consists of:
- Merge commit (
6defd54af) — mergingmaininto the feature branch - Logging PR (#3007) — adds performance logging for Doltgres database operations
Feature code unchanged: The 9 files implementing the durable delegated tool approval feature (tool-wrapper.ts, agentExecution.ts, agentExecutionSteps.ts, generateTaskHandler.ts, relationTools.ts, relation-tools.ts, tool-approval.ts, Agent.ts, agent-types.ts) have no changes in this delta.
The merged logging additions are in unrelated files:
function-tools.ts— slowwithReftimingTriggerService.ts— execution dispatch loggingbranchScopedDb.ts/ref.ts— middleware timingref-helpers.ts/ref-scope.ts— connection/checkout timing
These are standard observability improvements that don't interact with the approval flow.
✅ Prior Issues Remain Resolved
All issues from prior reviews (pullfrog + 4 claude reviews) were addressed in earlier commits:
- ✅ Artifact validation with
typeofchecks - ✅ SSE streaming error handling with try-catch
- ✅ Durable hook timeout documented (external cleanup job)
- ✅ Logging for delegated approval debugging
- ✅ Error logging when
pendingDurableApprovalsuppresses exceptions - ✅
baseUrldeviation documented - ✅ Continuation prompt history dependency documented
⚠️ Missing Changeset
This PR still needs a changeset for the durable delegated tool approval feature:
pnpm bump patch --pkg agents-api "Add support for tool approvals in delegated sub-agents during durable execution"💡 APPROVE WITH SUGGESTIONS
Summary: The delta contains only merged-in logging changes from PR #3007 — no modifications to the feature implementation. All prior review feedback remains addressed. The only outstanding item is the missing changeset, which should be added before merging. Ship it! 🚀
Reviewers (0)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
| Total | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Note: Delta review — no sub-reviewers dispatched since feature code is unchanged. Only merged-in logging changes from PR #3007.
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low | Review Scope: Delta
This is a re-review scoped to changes since the last automated review (6defd54af → 46a02c31a).
Delta Analysis
Single commit: 46a02c31a fix: use 'as const' for tool_calls type literal to satisfy typecheck
The change is a trivial TypeScript type narrowing fix:
- type: 'tool_calls',
+ type: 'tool_calls' as const,This ensures the return type is properly narrowed to the literal 'tool_calls' for correct type inference in the CallLlmResult union type. No functional change.
✅ Prior Issues Remain Resolved
Verified all fixes from prior reviews are still in place:
| Prior Issue | Verification |
|---|---|
| 🟠 Artifact validation | ✅ tool-wrapper.ts:232-245 — typeof checks before using delegatedToolCallId/delegatedToolName |
| 🟠 SSE streaming error handling | ✅ agentExecutionSteps.ts:597-628 — try-catch with error logging and re-throw |
| 🟠 Durable hook timeout | ✅ agentExecution.ts:94-97 — documented cleanup strategy via external job |
| 🟡 Delegated approval logging | ✅ agentExecution.ts:87-92 — logs hookToolCallId, parentToolCallId, isDelegated |
| 🟡 Error logging when suppressing | ✅ agentExecutionSteps.ts:559-567 — logs error context before continuing |
| 🟡 generateTaskHandler error logging | ✅ generateTaskHandler.ts:620-627 — logs toolCallId, toolName, error message |
| 🟡 baseUrl convention | ✅ agentExecutionSteps.ts:123-128 — documented intentional deviation |
| 🟡 Continuation prompt dependency | ✅ tool-wrapper.ts:110-114 — documented history storage fix |
Architecture Assessment
The artifact-based signaling pattern for durable delegated approvals is well-designed:
- Artifact flow — Sub-agents return
durable-approval-requiredartifacts that the parent'stool-wrapperdetects and propagates throughpendingDurableApproval - Re-delegation loop prevention —
isPostApprovalflag switches to continuation prompt after approval rounds - Delegation metadata forwarding —
durableWorkflowRunIdandapproved_tool_callsflow through A2A metadata - SSE event streaming — Delegated approvals stream the correct
toolCallIdfrom the sub-agent
⚠️ Missing Changeset
This PR still needs a changeset for the durable delegated tool approval feature:
pnpm bump patch --pkg agents-api "Add support for tool approvals in delegated sub-agents during durable execution"✅ APPROVE
Summary: The delta is a trivial TypeScript type narrowing fix (as const). All prior review feedback has been addressed and verified. The implementation is solid — artifact-based signaling cleanly replaces the in-memory pub/sub for durable delegated approvals, comprehensive error handling with logging, and the isPostApproval continuation prompt correctly breaks the re-delegation loop.
Add the changeset before merging, then ship it! 🚀
Reviewers (0)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
| Total | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Note: Delta review — no sub-reviewers dispatched since the change is a trivial type annotation (as const). All prior findings verified as still resolved.
Ito Test Report ❌11 test cases ran. 1 failed, 10 passed. Across 11 total test cases, 10 passed and 1 failed, so the unified run is a failure due to a single high-severity production defect despite broad delegated-approval coverage passing. The critical finding is that after delegated approval succeeds, the reconnect endpoint (/run/api/executions/{executionId}/stream) reads only the default namespace and drops post-approval continuation/completion events (introduced by this PR), while all other verified behaviors worked as designed, including durable playground/OpenAI-compatible approval flows, strict delegated toolCallId token binding, /run/api/chat mixed/unknown/out-of-order idempotent handling and validation, mobile approval actionability, and single-resolution approval state. ❌ Failed (1)
|












Summary