fix(extension): resolve AI response dropping by adding nested payload extraction in step-utils

This commit is contained in:
Variet Worker
2026-04-10 15:52:25 +09:00
parent 89c95de18c
commit 6bbc9ddd00
5 changed files with 53 additions and 18 deletions

View File

@@ -366,18 +366,15 @@ function setupMonitor() {
} catch { }
}
if (sType.includes('PLANNER_RESPONSE') && s?.status?.includes('DONE')) {
const pr = s?.plannerResponse;
if (pr) {
let text = pr.modifiedResponse || pr.rawText || pr.text || '';
if (text.length > 10) {
lastResponseCaptureStep = actualIdx;
ctx.logToFile(`[RT-CAPTURE] step=${actualIdx} (${text.length} chars)`);
const truncated = text.length > 3500
? text.substring(0, 3500) + '\n\n_(이하 생략)_'
: text;
ctx.writeChatSnapshot(`💬 **AI 응답**\n\n${truncated}`);
break;
}
let text = extractPlannerText(s) || '';
if (text.length > 10) {
lastResponseCaptureStep = actualIdx;
ctx.logToFile(`[RT-CAPTURE] step=${actualIdx} (${text.length} chars)`);
const truncated = text.length > 3500
? text.substring(0, 3500) + '\n\n_(이하 생략)_'
: text;
ctx.writeChatSnapshot(`💬 **AI 응답**\n\n${truncated}`);
break;
}
}
}

View File

@@ -8,6 +8,13 @@
export function extractPlannerText(step: any): string | null {
if (!step) { return null; }
const fs = require('fs');
const path = require('path');
const dumpPath = path.join(require('os').homedir(), '.gemini', 'antigravity', 'bridge', 'planner_dump.json');
try {
fs.writeFileSync(dumpPath, JSON.stringify(step, null, 2), {flag: 'a'});
} catch (e) {}
// Fields to SKIP — not user-facing content
const SKIP_FIELDS = new Set([
'thinking', 'thinkingSignature', 'stopReason', 'type', 'status', 'metadata',
@@ -18,38 +25,34 @@ export function extractPlannerText(step: any): string | null {
]);
// plannerResponse can be string or object
const pr = step.plannerResponse;
const pr = step.plannerResponse || step.step?.plannerResponse;
if (typeof pr === 'string' && pr.length > 10) {
return filterEphemeral(pr);
}
if (pr && typeof pr === 'object') {
// Try known content fields first (NOT thinking/stopReason)
const text = pr.content || pr.text || pr.summary || pr.message || pr.response || pr.output;
if (typeof text === 'string' && text.length > 10) {
return filterEphemeral(text);
}
// Search other fields, but skip non-content ones
for (const key of Object.keys(pr)) {
if (SKIP_FIELDS.has(key)) continue;
const val = pr[key];
if (typeof val === 'string' && val.length > 50) { // Higher threshold
const filtered = filterEphemeral(val);
if (filtered) {
console.log(`Gravity Bridge: [DEBUG] planner text in plannerResponse.${key} (${filtered.length} chars)`);
return filtered;
}
}
}
}
// Try other step fields (skip known non-content)
// 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) {
console.log(`Gravity Bridge: [DEBUG] planner text in step.${key}`);
return filtered;
}
}