runtime ArgumentValidationError when APIs expect an Id<"threads">
With @convex-dev/agent@0.2.7, you cannot type threadId as v.id("threads")?
Convex’s codegen does not expose components.agent in _generated/api, and the "threads" table is not registered as a first-class TableName?
2 Replies
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!
We’re integrating @convex-dev/agent into our Convex app. Each businessPlan record needs to store the agent threadId so we can call generateText, listThreadMessages, etc.
What we expected Schema like:
businessPlans: defineTable({
title: v.string(),
userId: v.id("users"),
threadId: v.optional(v.id("threads")),
components.agent.threads.create Thread should return an _id: Id<"threads"> we can store.
Then listThreadMessages etc. should accept it cleanly.
What we actually see On @convex-dev/agent@0.2.7, convex/_generated/api.js has no components.agent at all.
Codegen rejects v.id("threads") or v.id("agent_threads"): Type '"threads"' does not satisfy the constraint 'TableNames | SystemTableNames' So we had to fall back to: threadId: v.optional(v.string()) That compiles, but at runtime Convex still expects a threads ID in some calls.
Logs show failures like:
[CONVEX Q(threads:getThread)] ArgumentValidationError: Value does not match validator. Path: .threadId Value: "1" Validator: v.id("threads")
For extra context, here are my own debug logs showing the mismatch:
createThread result: { _id: 'm572jn4vswy26sk40t4nka6bj17qqd0c', ... }
storing threadId: m572jn4vswy26sk40t4nka6bj17qqd0c
plan.threadId before generateText: m572jn4vswy26sk40t4nka6bj17qqd0c
[CONVEX Q(threads:getThread)] ArgumentValidationError
Path: .threadId
Value: "1"
Validator: v.id("threads")
So the value is correct in my app and DB, but by the time threads:getThread runs inside the agent package it’s being turned into "1". Is this a known issue in @convex-dev/agent@0.2.7?