EthanbgraberE
Convex Community4mo ago
3 replies
Ethanbgraber

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?
Was this page helpful?