Skip to content

Conversation

@VaguelySerious
Copy link
Member

@VaguelySerious VaguelySerious commented Jan 12, 2026

This PR adds example tool definitions for sleep and for a human-approval tool using workflow hooks.

It also polishes the loading and error UI states.

Screenshot 2026-01-12 at 4 42 17 PM Screenshot 2026-01-12 at 4 43 11 PM

vercel[bot]

This comment was marked as resolved.

vercel bot and others added 3 commits January 12, 2026 15:44
…st without checking response status or handling errors, leading to silent failures and confusing user experience

Co-authored-by: VaguelySerious <[email protected]>
… - the type annotation includes 'price: number', but the destructuring pattern doesn't extract it, causing the price parameter to be accepted but never used.

Co-authored-by: VaguelySerious <[email protected]>
…nts/use-multi-turn-chat` that cannot be found. This is a missing module import that needs to be corrected or the file needs to be created.

This commit fixes the issue reported at app/page.tsx:25

## Unused import causes TypeScript compilation failure

**What fails:** TypeScript compiler fails when building the flight-booking-app with Next.js due to a missing module that was imported but never used.

**How to reproduce:**
```bash
cd flight-booking-app
pnpm install
pnpm run build
```

**Result (before fix):**
```
./app/page.tsx:25:34
Type error: Cannot find module '@/components/use-multi-turn-chat' or its corresponding type declarations.

[0m [90m 23 |[39m [36mimport[39m type { [33mMyUIMessage[39m } [36mfrom[39m [32m"@/schemas/chat"[33m[39m
 [90m 24 |[39m [36mimport[39m { [33mBookingApproval[39m } [36mfrom[39m [32m"@/components/booking-approval"[33m[39m
[31m[1m>[22m[39m[90m 25 |[39m [36mimport[39m { useMultiTurnChat } [36mfrom[39m [32m"@/components/use-multi-turn-chat"[33m[39m
```

**Root cause:** Line 25 of `app/page.tsx` imports `useMultiTurnChat` from a non-existent module. The hook is imported but never used anywhere in the component.

**Fix:** Removed the unused import statement on line 25.

**Result (after fix):** Build completes successfully with all static pages generated.

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: VaguelySerious <[email protected]>
Comment on lines +3 to +12
export async function POST(request: Request) {
const { toolCallId, approved, comment } = await request.json();
// Schema validation happens automatically
// Can throw a zod schema validation error, or a
await bookingApprovalHook.resume(toolCallId, {
approved,
comment,
});
return Response.json({ success: true });
}
Copy link
Collaborator

@pranaygp pranaygp Jan 12, 2026

Choose a reason for hiding this comment

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

we should just use webhook (with custom token mode if needed) since the API route isn't really doing much

seems simpler

imo only use hook when you need more control. recommend webhook preferably whenever we can (and make recs if there's something missing from webhook api we can improve)

import { defineHook } from 'workflow';
import { z } from 'zod';

export const bookingApprovalHook = defineHook({
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment re: using webhook instead :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

webhook should support zod schemas too with validation

Comment on lines +366 to +372
sleep: {
description: 'Pause execution for a specified duration',
inputSchema: z.object({
durationMs: z.number().describe('Duration to sleep in milliseconds'),
}),
execute: executeSleep,
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

for future, we should really ship @workflow/ai/tools with sleepTool amongst other tools (just like @cramforce shipped bashtool for just bash). We can write a nicer, longer description with example usage to encourage the patterns we like

Copy link
Collaborator

@pranaygp pranaygp left a comment

Choose a reason for hiding this comment

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

looks great but would love if we can change hook to webhook

@VaguelySerious
Copy link
Member Author

Will do the webhook change in #23

@VaguelySerious VaguelySerious merged commit 4870e78 into main Jan 13, 2026
3 checks passed
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.

3 participants