fix(cli): handle malformed AskUserQuestion data from LLM (#770)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2026-01-31 23:24:06 -08:00
committed by GitHub
parent f228ab18f8
commit dba41d760c
2 changed files with 9 additions and 4 deletions

View File

@@ -9264,10 +9264,13 @@ ${SYSTEM_REMINDER_CLOSE}
parseMemoryPreference(questions, answers);
// Format the answer string like Claude Code does
const answerParts = questions.map((q) => {
const answer = answers[q.question] || "";
return `"${q.question}"="${answer}"`;
});
// Filter out malformed questions (LLM might send invalid data)
const answerParts = questions
.filter((q) => q.question)
.map((q) => {
const answer = answers[q.question] || "";
return `"${q.question}"="${answer}"`;
});
const toolReturn = `User has answered your questions: ${answerParts.join(", ")}. You can now continue with the user's answers in mind.`;
const precomputedResult: ToolExecutionResult = {

View File

@@ -60,6 +60,8 @@ export function parseMemoryPreference(
answers: Record<string, string>,
): boolean {
for (const q of questions) {
// Skip malformed questions (LLM might send invalid data)
if (!q.question) continue;
const questionLower = q.question.toLowerCase();
const headerLower = q.header?.toLowerCase() || "";