fix(Backend): Gravity Bridge response extraction & bot exception crash loop

* Restore step.content.parts traversal missing in prior bugfix
* Catch wide exceptions in bot.py chat_snapshot_scanner and move broken files to .json.failed to prevent loop aborts blocking the pending queue
This commit is contained in:
Variet Worker
2026-04-10 16:33:02 +09:00
parent b88e75b075
commit e745744636
4 changed files with 29 additions and 11 deletions

View File

@@ -46,17 +46,25 @@ export function extractPlannerText(step: any): string | null {
}
}
// Try other step fields
for (const key of Object.keys(step)) {
if (SKIP_FIELDS.has(key) || key === 'plannerResponse') continue;
const val = step[key];
if (typeof val === 'string' && val.length > 50) {
const filtered = filterEphemeral(val);
if (filtered) {
return filtered;
}
}
// Fallback: nested fields not caught by top-level string iteration
if (step.content?.parts) {
let txt = '';
for (const p of step.content.parts) { if (p?.text) txt += p.text; }
if (txt.length > 10) return filterEphemeral(txt);
}
if (step.parts) {
let txt = '';
for (const p of step.parts) { if (p?.text) txt += p.text; }
if (txt.length > 10) return filterEphemeral(txt);
}
if (step.metadata?.text && step.metadata.text.length > 10) {
return filterEphemeral(step.metadata.text);
}
if (step.rawOutput) {
const txt = typeof step.rawOutput === 'string' ? step.rawOutput : JSON.stringify(step.rawOutput);
if (txt.length > 10) return filterEphemeral(txt);
}
return null;
}