Skip to content
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

'InvalidToolArgumentsError' error is thrown to parent scope in streamUi #2348

Open
defless opened this issue Jul 19, 2024 · 0 comments
Open
Labels
ai/rsc bug Something isn't working

Comments

@defless
Copy link

defless commented Jul 19, 2024

Description

When a zod schema validation error occurs in a streamUI tool-call, the nearest ErrorBoundary is triggered but the error is also thrown to parent scope.

Screenshot 2024-07-19 at 15 45 36

Am I missing something or it just what it's not supposed to do as specified here ?

// During the stream rendering, we don't want to throw the error to the
// parent scope but only let the React's error boundary to catch it.

Code example

export async function submitUserMessage (input: string) {

  const { tools, openai } = ai();
  const aiState = getMutableAIState();

  aiState.update([
    ...aiState.get(),
    { role: 'user', content: input, id: generateId() },
  ]);

  const ui = await streamUI({
    model: openai('gpt-3.5-turbo'),
    system: ``,
    messages: [...aiState.get()],
    tools: tools(aiState),
    toolChoice: 'required',
  });

  return {
    id: generateId(),
    display: (
      <ErrorBoundary fallback="error">
          { ui.value }
      </ErrorBoundary>),
    )
  };
}

Additional context

I tried to catch this error at different levels (server action & client side), but its not working.

@lgrammel lgrammel added bug Something isn't working ai/rsc labels Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/rsc bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants