Skip to content

Conversation

@grimlockbot
Copy link
Contributor

@grimlockbot grimlockbot bot commented Feb 2, 2026

Summary

This implements Issue #128 - the key fix that makes HITL (Human-In-The-Loop) work for refunds and email transfers.

Changes

Type Updates

  • Added toolCalls and requiresApproval fields to DraftOutput type in types.ts
  • Updated SupportDraftCreatedEvent and SupportDraftValidatedEvent to include tool call fields

Draft Step (draft.ts)

  • Added useAgentMode option that uses runSupportAgent instead of raw generateText
  • When agent mode is enabled, tool calls (like processRefund, transferPurchase) are captured
  • Agent determines requiresApproval based on tool types used

Pipeline Threading

  • draft-response.ts: Now enables agent mode and passes toolCalls/requiresApproval through
  • validate-draft.ts: Forwards tool call fields to downstream workflows
  • handle-validated-draft.ts:
    • Detects tool-based approvals (requiresApproval && hasToolCalls)
    • Creates ActionsTable records with type: 'tool-execution' instead of send-draft
    • Includes toolCalls in action parameters
    • Emits SUPPORT_APPROVAL_REQUESTED with correct action type

Tests

  • Added unit tests for tool-based approval detection logic
  • Tests cover action type determination and parameter building

Flow

  1. Customer requests refund
  2. Agent drafts response and proposes processRefund tool call
  3. requiresApproval: true detected → ActionsTable record created with type: 'tool-execution'
  4. Slack shows approval request with tool details
  5. On approval, execute-approved-action processes the tool calls (already implemented)

Acceptance Criteria

  • Agent can propose refund → ActionsTable record created with toolCalls
  • Existing draft flow (no tools) still works
  • Tests pass

Note: Slack notification and integration testing will be verified in staging.

Closes #128

This implements Issue #128 - the key fix that makes HITL work for refunds/email transfers.

Changes:
- Add toolCalls and requiresApproval fields to DraftOutput type
- Add useAgentMode option to draft step that uses runSupportAgent
- Pass toolCalls through draft-response → validate-draft → handle-validated-draft
- Create ActionsTable records with type 'tool-execution' for approval-requiring tools
- Include toolCalls in SUPPORT_APPROVAL_REQUESTED event parameters
- Add tests for tool-based approval detection logic

The existing execute-approved-action.ts already handles toolCalls in parameters,
so tool execution on approval should work end-to-end.

Closes #128
@vercel
Copy link

vercel bot commented Feb 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
skill-support-agent-front Ready Ready Preview, Comment Feb 2, 2026 9:54pm
skill-support-agent-slack Ready Ready Preview, Comment Feb 2, 2026 9:54pm
skill-support-agent-web Ready Ready Preview, Comment Feb 2, 2026 9:54pm

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.

Fix: Generate ActionsTable records for tool-based flows

0 participants