Ethanbgraber
Ethanbgraber13h ago

Major Agent integration errors on my large project

Here is the problem Claude-4.1-opus is telling me Why Adding Convex Agent Breaks Your Types: The Core Issue: When you add ...agent.schema to your schema, the agent component introduces its own tables and type system. This fundamentally changes how TypeScript infers Id types across your ENTIRE codebase. What's happening: // BEFORE agent: TypeScript knows this returns Id<"childRegistry"> const child = await ctx.db.get(childId); return child._id; // ✅ TypeScript infers Id<"childRegistry"> // AFTER agent: TypeScript gets confused const child = await ctx.db.get(childId); return child._id; // ❌ TypeScript now infers Id<string> (generic) Why This Happens Agent uses generic types internally - The agent component likely uses Id<string> for flexibility Type inference changes globally - Adding agent schema affects how TypeScript analyzes your whole codebase Convex components limitation - This is a known issue when integrating components into existing large projects thoughts?
2 Replies
Convex Bot
Convex Bot13h ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Ethanbgraber
EthanbgraberOP10h ago
The options its giving me: The Core Issue The Convex agent component changes how TypeScript infers Id types globally across your entire codebase. This is not a bug in your code - it's an architectural incompatibility. Your Options: Option 1: Direct OpenAI Integration (What works) Use OpenAI directly without Convex agent - your code compiles cleanly. Option 2: Separate Agent Project Create a new Convex project just for agents and communicate via HTTP actions. Option 3: Wait for Convex Fix This is a Convex component architecture issue that needs to be fixed by them. The harsh reality: The Convex agent component is not compatible with complex existing Convex projects. You were right to be frustrated - this isn't your fault! Should I implement Option 1 (direct OpenAI) so you can move forward, or Option 2 (separate project)? i tried more and got more information Looking back at the documentation you provided, I cannot find any mention of this compound index incompatibility. The docs you shared: Convex Agents docs Getting Started guide GitHub repo Stack article None of these mention that the agent component breaks compound index queries or changes how .eq() chaining works. This appears to be an undocumented issue. The problem we're seeing: Normal Convex: q.eq("field1", value).eq("field2", value) ✓ works With Agent: Same syntax gives "Property 'eq' does not exist on type 'IndexRange'" ✗ The fact that adding ...agent.schema to your schema breaks TypeScript's understanding of index queries across your entire codebase isn't mentioned in any official documentation I can see. This is likely a bug or undocumented limitation in the Convex Agent component that should be reported to the Convex team. The component appears to modify the global type system in an incompatible way.

Did you find this page helpful?