Docs
Cloudflare
Railway
CodeRabbit
Netlify
OpenRouter
AG Grid
Clerk
WorkOS
SerpAPI
Unkey
Sentry
Electric
Prisma
Cloudflare
Railway
CodeRabbit
Netlify
OpenRouter
AG Grid
Clerk
WorkOS
SerpAPI
Unkey
Sentry
Electric
Prisma
Class References
Function References
Interface References
Type Alias References
Variable References

ChatMiddlewarePhase

Type Alias: ChatMiddlewarePhase

ts
type ChatMiddlewarePhase = 
  | "init"
  | "beforeModel"
  | "modelStream"
  | "beforeTools"
  | "afterTools"
  | "structuredOutput";
type ChatMiddlewarePhase = 
  | "init"
  | "beforeModel"
  | "modelStream"
  | "beforeTools"
  | "afterTools"
  | "structuredOutput";

Defined in: packages/ai/src/activities/chat/middleware/types.ts:25

Phase of the chat middleware lifecycle.

  • 'init': Initial config transform before the chat engine starts
  • 'beforeModel': Before each adapter chatStream call (per agent iteration)
  • 'modelStream': During model streaming
  • 'beforeTools': Before tool execution phase
  • 'afterTools': After tool execution phase
  • 'structuredOutput': During the final structured-output adapter call (set for chunks from adapter.structuredOutputStream or the synthesized fallback)