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
description: "Look up available tags in the environment",
57
57
parameters: z.object({
58
58
query: z.string().optional().describe("Optional search query to filter tags"),
@@ -69,8 +69,8 @@ export async function processAIFilter(
69
69
total: tags.tags.length,
70
70
};
71
71
},
72
-
},
73
-
lookupVersions: {
72
+
}),
73
+
lookupVersions: tool({
74
74
description:
75
75
"Look up available versions in the environment. If you specify `isCurrent` it will return a single version string if it finds one. Otherwise it will return an array of version strings.",
76
76
parameters: z.object({
@@ -107,8 +107,8 @@ export async function processAIFilter(
107
107
versions: versions.versions.map((v)=>v.version),
108
108
};
109
109
},
110
-
},
111
-
lookupQueues: {
110
+
}),
111
+
lookupQueues: tool({
112
112
description: "Look up available queues in the environment",
113
113
parameters: z.object({
114
114
query: z.string().optional().describe("Optional search query to filter queues"),
@@ -129,8 +129,8 @@ export async function processAIFilter(
129
129
total: queues.success ? queues.queues.length : 0,
130
130
};
131
131
},
132
-
},
133
-
lookupTasks: {
132
+
}),
133
+
lookupTasks: tool({
134
134
description:
135
135
"Look up available tasks in the environment. It will return each one. The `slug` is used for the filtering. You also get the triggerSource which is either `STANDARD` or `SCHEDULED`",
136
136
parameters: z.object({}),
@@ -141,8 +141,9 @@ export async function processAIFilter(
141
141
total: tasks.length,
142
142
};
143
143
},
144
-
},
144
+
}),
145
145
},
146
+
maxSteps: 5,
146
147
prompt: `You are an AI assistant that converts natural language descriptions into structured filter parameters for a task run filtering system.
@@ -177,20 +179,73 @@ Use the available tools to look up actual tags, versions, queues, and tasks in t
177
179
178
180
Unless they specify they only want root runs, set rootOnly to false.
179
181
182
+
IMPORTANT: Return ONLY the filters that are explicitly mentioned or can be reasonably inferred. If the description is unclear or doesn't match any known patterns, return an empty filters object {} and explain why in the explanation field.
183
+
184
+
The filters object should only contain the fields that are actually being filtered. Do not include fields with empty arrays or undefined values.
185
+
186
+
CRITICAL: The response must be a valid JSON object with exactly this structure:
187
+
{
188
+
"filters": {
189
+
// only include fields that have actual values
190
+
},
191
+
"explanation": "string explaining what filters were applied"
192
+
}
193
+
180
194
Convert the following natural language description into structured filters:
181
195
182
196
"${text}"
183
197
184
198
Return only the filters that are explicitly mentioned or can be reasonably inferred. If the description is unclear or doesn't match any known patterns, return an empty filters object and explain why in the explanation field.`,
185
199
});
186
200
201
+
// Add debugging to see what the AI returned
202
+
logger.info("AI filter response",{
203
+
text,
204
+
environmentId: environment.id,
205
+
result: result.experimental_output,
206
+
filters: result.experimental_output.filters,
207
+
});
208
+
209
+
// Validate the filters against the schema to catch any issues
0 commit comments