// showcase:automation:start /// A request becomes a saved draft. Only a requested row starts it: saving the /// draft writes a new version, which is a create event too, and must not rerun it. @actor @trigger(event="graph.node.created.v1:research:researchBrief") @filter(row => row.status == "requested") automation prepareResearchBrief { args { id string! question string! agentId string! } sources := logic relevantResearchFiles(question: args.question) if sources.empty() { mutation saveResearchBrief( briefId: args.id, question: args.question, agentId: args.agentId, status: "no_sources", answer: "No indexed sources found.", sources: [] ) return } answer := logic draftResearchAnswer( agentId: args.agentId, question: args.question, sources: sources ) mutation saveResearchBrief( briefId: args.id, question: args.question, agentId: args.agentId, status: "draft", answer: answer, sources: sources ) } // showcase:automation:end