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

Adding useAgentChat into an open-next worker causes not valid JSON bug #75

Open
moesmufti opened this issue Mar 12, 2025 · 3 comments
Open

Comments

@moesmufti
Copy link

I'm trying to implement the agent-sdk into an existing chat application that runs opennext on a cloudflare worker.

Adding useAgent works fine, but when I add useAgentChat (following the readme), I see:

Image

The stack shows that it triggers on the component that holds the useAgentChat hook within index.tsx (so the subcomponent in there, ).

I tried both the readme version of useChatAgent as well as the implementation in the starter, both cause this.

Short BG: I have the AI agent itself on a separate worker that follows the AI agent chat starter to test, and I want to invoke it in my existing chat application.

@threepointone
Copy link
Collaborator

I'm going to guess this is because of the /get-messages call, (which I"m going to rewrite) but I can't say more without a repro

@moesmufti
Copy link
Author

moesmufti commented Mar 12, 2025

Created a very basic repro repo here: https://github.com/moesmufti/opennext-agents-example

The Readme covers all the steps I took to get there. What's funny is that the same hook (useAgentChat) is causing an issue upon implementation, but in the repro the error is different (not invalid JSON but 'can't resolve @ai-sdk/react'). When commenting out the specific hook the error disappears (normal useAgent works).

I have a feeling they are related issues.

@threepointone
Copy link
Collaborator

awesome, I'll dig into this today

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

No branches or pull requests

2 participants