fix: Filter out empty plans (#644)

This commit is contained in:
Brace Sproul 2025-08-01 13:42:47 -07:00 • committed by GitHub
parent c70da1b1c2
commit 041cb4aca6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -102,6 +102,22 @@ export async function generatePlan(
...inputMessages,
]);
// Filter out empty plans
response.tool_calls = response.tool_calls?.map((tc) => {
if (tc.id === sessionPlanTool.name) {
return {
...tc,
args: {
...tc.args,
plan: (tc.args as z.infer<typeof sessionPlanTool.schema>).plan.filter(
(p) => p.length > 0,
),
},
};
}
return tc;
});
const toolCall = response.tool_calls?.[0];
if (!toolCall) {
throw new Error("Failed to generate plan");