Skip to content
Discussion options

You must be logged in to vote

@brenbitY2K

1. Is client-side persistence the recommended pattern?

No. We recommend either doing client-side or workflow-side persistence, depending on your specific needs. In most cases, this will be workflow-side persistence, since clients aren't guaranteed to be connected on workflow finish.

As of @workflow/ai@4.0.1-beta.46, you can persist messages like so:

export async function chat(initialUiMessages: UIMessage[]) {
  "use workflow";
  
  const writable = getWritable<UIMessageChunk>();
  const agent = new DurableAgent({
    // ...
  });

  const { uiMessages, messages: modelMessages } = await agent.stream({
    messages: convertToModelMessages(initialUiMessages),
    collectUIMessage…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pranaygp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants