feat: real-time PLANNER_RESPONSE capture on every delta>0 during RUNNING
This commit is contained in:
@@ -1489,6 +1489,46 @@ function setupMonitor() {
|
||||
lastKnownStepCount = currentCount;
|
||||
if (delta > 0) {
|
||||
console.log(`Gravity Bridge: [POLL#${pollCount}] +${delta} steps (${currentCount}) "${currentTitle}"`);
|
||||
// Real-time response capture: fetch latest steps on every delta>0
|
||||
if (isRunning && currentCount > lastResponseCaptureStep && sdk) {
|
||||
try {
|
||||
const rtOffset = Math.max(0, currentCount - 3);
|
||||
const rtResp = await sdk.ls.rawRPC('GetCascadeTrajectorySteps', {
|
||||
cascadeId: bestSessionId,
|
||||
stepOffset: rtOffset,
|
||||
verbosity: 1, // DEBUG — includes plannerResponse text
|
||||
});
|
||||
if (rtResp?.steps?.length > 0) {
|
||||
for (let ri = rtResp.steps.length - 1; ri >= 0; ri--) {
|
||||
const s = rtResp.steps[ri];
|
||||
const sType = s?.type || '';
|
||||
const actualIdx = rtOffset + ri;
|
||||
if (actualIdx <= lastResponseCaptureStep)
|
||||
continue;
|
||||
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;
|
||||
logToFile(`[RT-CAPTURE] step=${actualIdx} (${text.length} chars)`);
|
||||
const truncated = text.length > 1800
|
||||
? text.substring(0, 1800) + '\n\n_(이하 생략)_'
|
||||
: text;
|
||||
writeChatSnapshot(`💬 **AI 응답**\n\n${truncated}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (rte) {
|
||||
// Non-critical — don't spam logs
|
||||
if (pollCount <= 5)
|
||||
logToFile(`[RT-CAPTURE] error: ${rte.message.substring(0, 80)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Log session state on EVERY poll for diagnostics
|
||||
const statusStr = String(bestSession.status || 'UNKNOWN');
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user