Zxies
Zxies7d ago

Trigger on agent component tables

Hi Convex team, I'm working with agent component but running in some problem, the problem is because the tables are maintained internally, I'm not able to use trigger with type safty
// register a function to run when a `ctx.db.insert`, `ctx.db.patch`, `ctx.db.replace`, or `ctx.db.delete` changes the "users" table
triggers.register("users", async (ctx, change) => {
console.log("user changed", change);
});
// register a function to run when a `ctx.db.insert`, `ctx.db.patch`, `ctx.db.replace`, or `ctx.db.delete` changes the "users" table
triggers.register("users", async (ctx, change) => {
console.log("user changed", change);
});
I want to use the messages table from agent component here but I'm getting type error, what could I do? Thanks
4 Replies
Convex Bot
Convex Bot7d 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!
Sorin
Sorin7d ago
This is intended to work a but different. https://stack.convex.dev/triggers it is meant to be registered and then it creates new mutation function. You are supposed to use this instead of the mutation from api. This will trigger the source mutation… I don’t think you can use it for components as you don’t have acces to the mutation functions used by components. You may have an onfinish step somewhere in the agent. That should be a valid way to get messages as they are sent
Database Triggers
Triggers automatically run code whenever data in a table changes. A library in the convex-helpers npm package allows you to attach trigger functions t...
Zxies
ZxiesOP5d ago
Yea, I have learned about trigger, but what if I want to use triggers in agent component tables, how can I use it? is there any solution?
Clever Tagline
This thread contains some insights from Ian on why the API boundary exists that prevents direct access to component resources, one of the biggest being breaking changes if a component's internal design is modified: https://discord.com/channels/1019350475847499849/1379981117083619463

Did you find this page helpful?