You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.playground.$agentParam/route.tsx
Copy file name to clipboardExpand all lines: apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.test.tasks.$taskParam/AIPayloadTabContent.tsx
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,7 @@ export function AIPayloadTabContent({
25
25
generateButtonLabel ="Generate payload",
26
26
placeholder,
27
27
examplePromptsOverride,
28
+
isAgent =false,
28
29
}: {
29
30
onPayloadGenerated: (payload: string)=>void;
30
31
payloadSchema?: unknown;
@@ -33,6 +34,7 @@ export function AIPayloadTabContent({
33
34
generateButtonLabel?: string;
34
35
placeholder?: string;
35
36
examplePromptsOverride?: string[];
37
+
isAgent?: boolean;
36
38
}){
37
39
const[prompt,setPrompt]=useState("");
38
40
const[isLoading,setIsLoading]=useState(false);
@@ -70,6 +72,7 @@ export function AIPayloadTabContent({
Copy file name to clipboardExpand all lines: apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.test.ai-generate-payload.tsx
@@ -233,6 +238,60 @@ async function getTaskFromDeployment(environmentId: string, taskIdentifier: stri
233
238
return{fileId: task.fileId};
234
239
}
235
240
241
+
functionbuildAgentClientDataPrompt(
242
+
taskIdentifier: string,
243
+
payloadSchema?: string,
244
+
currentPayload?: string
245
+
): string{
246
+
letprompt=`You are a JSON generator for client data (metadata) of a Trigger.dev chat agent with id "${taskIdentifier}".
247
+
248
+
IMPORTANT: You are generating ONLY the client data object — this is the metadata sent alongside each chat message. It is NOT the full task payload. Do NOT generate fields like "chatId", "messages", "trigger", or "idleTimeoutInSeconds" — those are internal transport fields managed by the framework.
249
+
250
+
The client data typically contains user context like user IDs, preferences, configuration, or session info. Return ONLY valid JSON wrapped in a \`\`\`json code block.
251
+
252
+
Requirements:
253
+
- Generate realistic, meaningful example data
254
+
- All string values should be plausible (real-looking IDs, names, etc.)
255
+
- The JSON must be valid and parseable
256
+
- Keep it simple — client data is usually a flat or shallow object`;
257
+
258
+
if(payloadSchema){
259
+
prompt+=`
260
+
261
+
The agent has the following JSON Schema for its client data:
262
+
\`\`\`json
263
+
${payloadSchema}
264
+
\`\`\`
265
+
266
+
Generate client data that strictly conforms to this schema.`;
267
+
}else{
268
+
prompt+=`
269
+
270
+
No JSON Schema is available for this agent's client data. Use the getTaskSourceCode tool to look up the agent's source code file.
271
+
272
+
IMPORTANT instructions for reading the source code:
273
+
- The file may contain multiple task/agent definitions. Find the one with id "${taskIdentifier}".
274
+
- Look for \`withClientData({ schema: ... })\` or \`clientDataSchema\` to find the expected client data shape.
275
+
- If using \`chat.agent()\` or \`chat.customAgent()\`, the client data is accessed via \`clientData\` in hooks and \`payload.metadata\` in raw tasks.
276
+
- Look for how \`clientData\` or \`payload.metadata\` is accessed/destructured to infer the shape.
277
+
- Do NOT generate the full ChatTaskWirePayload (messages, chatId, trigger, etc.) — ONLY the metadata/clientData portion.
278
+
- If no client data schema or usage is found, generate a simple \`{ "userId": "user_..." }\` object.`;
279
+
}
280
+
281
+
if(currentPayload){
282
+
prompt+=`
283
+
284
+
The current client data in the editor is:
285
+
\`\`\`json
286
+
${currentPayload}
287
+
\`\`\`
288
+
289
+
Use this as context but generate new client data based on the user's prompt.`;
0 commit comments