-
Notifications
You must be signed in to change notification settings - Fork 119
feat: Slack always uses durable execution mode with continuation stream #3006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9d0276f
65bb15f
c637f86
ecd719c
c611c59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ async function _agentExecutionWorkflow(payload: AgentExecutionPayload) { | |
| let currentSubAgentId = defaultSubAgentId; | ||
| let iterations = 0; | ||
| let approvalRound = 0; | ||
| let isPostApproval = false; | ||
|
|
||
| try { | ||
| while (iterations < maxTransfers) { | ||
|
|
@@ -61,10 +62,12 @@ async function _agentExecutionWorkflow(payload: AgentExecutionPayload) { | |
| workflowRunId, | ||
| streamNamespace, | ||
| taskId, | ||
| isPostApproval, | ||
| }); | ||
|
|
||
| if (llmResult.type === 'transfer') { | ||
| currentSubAgentId = llmResult.targetSubAgentId; | ||
| isPostApproval = false; | ||
| continue; | ||
| } | ||
|
|
||
|
|
@@ -78,7 +81,23 @@ async function _agentExecutionWorkflow(payload: AgentExecutionPayload) { | |
| continuationStreamNamespace: continuationNs, | ||
| }); | ||
|
|
||
| const token = `tool-approval:${payload.conversationId}:${workflowRunId}:${toolCall.toolCallId}`; | ||
| const hookToolCallId = llmResult.delegatedApproval?.toolCallId ?? toolCall.toolCallId; | ||
| const token = `tool-approval:${payload.conversationId}:${workflowRunId}:${hookToolCallId}`; | ||
|
|
||
| console.info( | ||
| JSON.stringify({ | ||
| msg: '[agentExecution] Creating tool approval hook', | ||
| hookToolCallId, | ||
| parentToolCallId: toolCall.toolCallId, | ||
| isDelegated: !!llmResult.delegatedApproval, | ||
| workflowRunId, | ||
| }) | ||
| ); | ||
anubra266 marked this conversation as resolved.
Show resolved
Hide resolved
anubra266 marked this conversation as resolved.
Show resolved
Hide resolved
anubra266 marked this conversation as resolved.
Show resolved
Hide resolved
anubra266 marked this conversation as resolved.
Show resolved
Hide resolved
anubra266 marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+87
to
+95
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Minor: Use structured logger instead of Issue: Using Why: The sibling file Fix: Add import and logger at module scope, then use structured logging: import { getLogger } from '../../../../logger';
const logger = getLogger('agentExecution');
// Then replace console.info with:
logger.info(
{
hookToolCallId,
parentToolCallId: toolCall.toolCallId,
isDelegated: !!llmResult.delegatedApproval,
workflowRunId,
},
'[agentExecution] Creating tool approval hook'
);Refs:
anubra266 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // The hook suspends the workflow until an external system resumes it. | ||
| // Unlike the in-process PendingToolApprovalManager (10-min timeout), durable | ||
| // hooks persist across restarts. Stale suspended workflows should be cleaned | ||
| // up by an external job that queries workflow_executions with status='suspended'. | ||
| const hook = toolApprovalHook.create({ token }); | ||
| const approvalResult = await hook; | ||
| approvalRound++; | ||
|
|
@@ -100,8 +119,18 @@ async function _agentExecutionWorkflow(payload: AgentExecutionPayload) { | |
| taskId, | ||
| preApproved: approvalResult.approved, | ||
| approvalReason: approvalResult.reason, | ||
| ...(llmResult.delegatedApproval | ||
| ? { | ||
| delegatedApproval: llmResult.delegatedApproval, | ||
| delegatedApprovalDecision: { | ||
| approved: approvalResult.approved, | ||
| reason: approvalResult.reason, | ||
| }, | ||
| } | ||
| : {}), | ||
| }); | ||
| } | ||
| isPostApproval = true; | ||
| continue; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.