fix: version 4.0.5 -- Propuestas de IA grandes ya no quedan cortadas

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Milton Gonzalez
2026-10-23 17:37:30 -05:00
parent 6d41e96ec1
commit f497da836c
6 changed files with 15 additions and 6 deletions
+2 -2
View File
@@ -120,7 +120,7 @@ export async function generateProjectPlan(projectId, description, lang, user) {
].filter(Boolean).join('\n'),
toolName: 'plan_de_proyecto',
schema: { type: 'object', properties: { activities: ACTIVITIES_SCHEMA }, required: ['activities'] },
maxTokens: 4000,
maxTokens: 12000,
});
await logAudit({ userId: user.id, action: 'ai_plan', entityType: 'project', entityId: projectId });
return { activities: cleanPlan(result.activities) };
@@ -192,7 +192,7 @@ export async function proposeNewProject({ objective, startDate, lang }, user) {
},
required: ['isProject'],
},
maxTokens: 4000,
maxTokens: 12000,
});
await logAudit({ userId: user.id, action: 'ai_new_project', entityType: 'project', entityId: null });
if (!result.isProject) throw new HttpError(422, 'Solo puedo ayudarte a crear proyectos. Describe el objetivo de un proyecto de trabajo.');
+3 -1
View File
@@ -40,7 +40,9 @@ export async function askStructured({ system, prompt, toolName, schema, maxToken
throw new HttpError(502, `Servicio de IA: ${detail}`);
}
// Consumo real de cada llamada (para estimar costos: ver precios del modelo en la consola).
console.log(`[ai] ${config.model} tokens entrada=${body?.usage?.input_tokens} salida=${body?.usage?.output_tokens}`);
console.log(`[ai] ${config.model} tokens entrada=${body?.usage?.input_tokens} salida=${body?.usage?.output_tokens} fin=${body?.stop_reason}`);
// Respuesta cortada por el tope de tokens: el JSON de la herramienta llega incompleto.
if (body?.stop_reason === 'max_tokens') throw new HttpError(502, 'La respuesta de la IA fue demasiado larga y quedo incompleta. Intenta con un objetivo mas acotado.');
const tool = body?.content?.find((c) => c.type === 'tool_use');
if (!tool?.input) throw new HttpError(502, 'La IA no devolvio un resultado valido');
return tool.input;