codeep 1.0.24 → 1.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -626,13 +626,33 @@ export async function runAgent(prompt, projectContext, options = {}) {
626
626
  toolCalls = textToolCalls;
627
627
  }
628
628
  }
629
- // If no tool calls, agent is done - simple and clean like Claude Code/Aider
629
+ // If no tool calls, check if model wants to continue or is really done
630
630
  if (toolCalls.length === 0) {
631
- console.error(`[DEBUG] No tool calls at iteration ${iteration}, agent finished`);
631
+ console.error(`[DEBUG] No tool calls at iteration ${iteration}`);
632
632
  // Remove <think>...</think> tags from response (some models include thinking)
633
633
  finalResponse = content.replace(/<think>[\s\S]*?<\/think>/gi, '').trim();
634
- // Trust the model - if it says it's done, it's done
635
- // No forcing, no blocking, no artificial requirements
634
+ // Check if model indicates it wants to continue (incomplete response)
635
+ const continueIndicators = [
636
+ 'let me', 'i will', 'i\'ll', 'now i', 'next i',
637
+ 'creating', 'writing', 'generating',
638
+ 'let\'s', 'going to', 'need to create', 'need to write'
639
+ ];
640
+ const lowerResponse = finalResponse.toLowerCase();
641
+ const wantsToContinue = continueIndicators.some(indicator => lowerResponse.includes(indicator));
642
+ // Also check if there were tool call parsing failures in this iteration
643
+ // by looking for incomplete actions (e.g., write_file without content)
644
+ const hasIncompleteWork = iteration < 10 && wantsToContinue && finalResponse.length < 500;
645
+ if (hasIncompleteWork) {
646
+ console.error(`[DEBUG] Model wants to continue, prompting for next action`);
647
+ messages.push({ role: 'assistant', content });
648
+ messages.push({
649
+ role: 'user',
650
+ content: 'Continue. Execute the tool calls now.'
651
+ });
652
+ continue;
653
+ }
654
+ // Model is done
655
+ console.error(`[DEBUG] Agent finished at iteration ${iteration}`);
636
656
  break;
637
657
  }
638
658
  // Add assistant response to history
@@ -204,20 +204,40 @@ function normalizeToolName(name) {
204
204
  export function parseOpenAIToolCalls(toolCalls) {
205
205
  if (!toolCalls || !Array.isArray(toolCalls))
206
206
  return [];
207
- return toolCalls.map(tc => {
207
+ const parsed = [];
208
+ for (const tc of toolCalls) {
209
+ const toolName = normalizeToolName(tc.function?.name || '');
210
+ if (!toolName)
211
+ continue;
208
212
  let parameters = {};
209
213
  try {
210
214
  parameters = JSON.parse(tc.function?.arguments || '{}');
211
215
  }
212
- catch {
213
- parameters = {};
216
+ catch (e) {
217
+ // JSON parsing failed - likely truncated response
218
+ console.error(`[DEBUG] Failed to parse tool arguments for ${toolName}:`, tc.function?.arguments?.substring(0, 100));
219
+ continue; // Skip this tool call entirely
214
220
  }
215
- return {
216
- tool: normalizeToolName(tc.function?.name || ''),
221
+ // Validate required parameters for specific tools
222
+ if (toolName === 'write_file' && (!parameters.path || parameters.content === undefined)) {
223
+ console.error(`[DEBUG] Skipping write_file with missing path or content`);
224
+ continue;
225
+ }
226
+ if (toolName === 'read_file' && !parameters.path) {
227
+ console.error(`[DEBUG] Skipping read_file with missing path`);
228
+ continue;
229
+ }
230
+ if (toolName === 'edit_file' && (!parameters.path || parameters.old_text === undefined || parameters.new_text === undefined)) {
231
+ console.error(`[DEBUG] Skipping edit_file with missing parameters`);
232
+ continue;
233
+ }
234
+ parsed.push({
235
+ tool: toolName,
217
236
  parameters,
218
237
  id: tc.id,
219
- };
220
- }).filter(tc => tc.tool);
238
+ });
239
+ }
240
+ return parsed;
221
241
  }
222
242
  /**
223
243
  * Parse tool calls from Anthropic response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeep",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "description": "AI-powered coding assistant built for the terminal. Multiple LLM providers, project-aware context, and a seamless development workflow.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",