#Thread schema

4 messages · Page 1 of 1 (latest)

left flint
#

Can I extend the threads schema using convex AI? If not, how can I implement it?

short trailBOT
#

Hi @left flint. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Currently, you cannot directly extend or customize the internal schema of the threads used by Convex AI Agents (i.e., the threads managed by the @convex-dev/agent package). The threads table is managed internally by the agent system, and attempts to reference it in your own schema (e.g., using v.id("threads")) are not supported and will result in type errors or runtime validation issues. This is a known limitation, as discussed in community support threads—developers have encountered issues when trying to store or reference thread IDs in their own tables, since the threads table is not exposed as a first-class table in your Convex project schema. As a workaround, developers often fall back to storing thread IDs as strings, but this can cause validation errors when interacting with agent APIs that expect a proper thread ID type Discord: runtime ArgumentValidationError when APIs expect an Id<"threads">.

If you need to associate additional metadata or custom fields with threads, the recommended approach is to create your own table (e.g., customThreads) in your schema. In this table, you can store a reference to the threadId (as a string or as a custom field), along with any additional fields you require. You would then manage the relationship between your custom table and the agent threads in your application logic.

Example:

export default defineSchema({
  customThreads: defineTable({
    threadId: v.string(), // Store the agent thread ID as a string
    myCustomField: v.string(),
    // ...other custom fields
  }),
  // ...other tables
});

You can then use this table to store and retrieve any extra data you want to associate with a thread.

#

In summary:

If you need to read or annotate the schema itself, Convex does not currently support extending the schema definition with custom metadata or annotations, though this is a requested feature Discord: Custom Metadata/Extending Schema.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: