fix: track ALL trajectories, detect new conversations, summary fallback per-traj

This commit is contained in:
2026-03-07 19:55:34 +09:00
parent 0c9664542e
commit 41f90b3b15
4 changed files with 142 additions and 109 deletions

Binary file not shown.

View File

@@ -282,13 +282,15 @@ function activate(context) {
}); });
} }
let pollFailCount = 0; let pollFailCount = 0;
let pollCount = 0;
async function pollConversations() { async function pollConversations() {
if (!lsPort) { if (!lsPort) {
return; return;
} }
if (pollFailCount > 3) { if (pollFailCount > 10) {
return; return;
} // stop after repeated failures } // stop after repeated failures
pollCount++;
try { try {
// Use getDiagnostics to get cascade-level conversation IDs // Use getDiagnostics to get cascade-level conversation IDs
const diag = await vscode.commands.executeCommand('antigravity.getDiagnostics'); const diag = await vscode.commands.executeCommand('antigravity.getDiagnostics');
@@ -302,33 +304,46 @@ function activate(context) {
} }
const isFirstPoll = Object.keys(lastStepIndex).length === 0; const isFirstPoll = Object.keys(lastStepIndex).length === 0;
if (isFirstPoll) { if (isFirstPoll) {
console.log(`Gravity Bridge: [LS] ${trajectories.length} recent trajectories from getDiagnostics`); console.log(`Gravity Bridge: [LS] ${trajectories.length} trajectories from getDiagnostics`);
const latest = trajectories[trajectories.length - 1];
console.log(`Gravity Bridge: [LS] latest: ${JSON.stringify(latest).substring(0, 400)}`);
} }
// Check the most recent trajectory for step count changes // Periodic debug every ~1 min (12 * 5s)
const latest = trajectories[trajectories.length - 1]; if (pollCount % 12 === 0) {
const agentId = latest.googleAgentId || ''; const summary = trajectories.map((t) => {
const trajId = latest.trajectoryId || ''; const id = (t.googleAgentId || '').substring(0, 8);
const stepIdx = latest.lastStepIndex ?? 0; return `${id}:s${t.lastStepIndex ?? '?'}`;
}).join(', ');
console.log(`Gravity Bridge: [LS] poll#${pollCount}${trajectories.length} trajs: [${summary}]`);
}
// Check ALL trajectories for step count changes
for (const traj of trajectories) {
const agentId = traj.googleAgentId || '';
const trajId = traj.trajectoryId || '';
const stepIdx = traj.lastStepIndex ?? 0;
const summary = traj.summary || '';
if (!agentId && !trajId) { if (!agentId && !trajId) {
return; continue;
} }
const key = agentId || trajId; const key = agentId || trajId;
const prev = lastStepIndex[key]; const prev = lastStepIndex[key];
if (prev === undefined) { if (prev === undefined) {
// First poll — initialize // First time seeing this trajectory — initialize
lastStepIndex[key] = stepIdx; lastStepIndex[key] = stepIdx;
console.log(`Gravity Bridge: [LS] initialized ${key.substring(0, 8)} at step ${stepIdx}`); if (isFirstPoll) {
return; console.log(`Gravity Bridge: [LS] init ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 30)}"`);
}
else {
// New trajectory appeared after first poll = new conversation!
console.log(`Gravity Bridge: [LS] NEW trajectory ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 40)}"`);
}
continue;
} }
if (stepIdx > prev) { if (stepIdx > prev) {
// New steps detected! Try to fetch them // New steps detected!
console.log(`Gravity Bridge: [LS] ${key.substring(0, 8)} new steps: ${prev}${stepIdx}`); console.log(`Gravity Bridge: [LS] ${key.substring(0, 8)} steps: ${prev}${stepIdx} "${summary.substring(0, 40)}"`);
// Try RPC to get full step text
const attempts = [ const attempts = [
{ method: 'GetCascadeTrajectorySteps', params: { googleAgentId: agentId, trajectoryId: trajId, startStepIndex: prev } }, { method: 'GetCascadeTrajectorySteps', params: { googleAgentId: agentId, trajectoryId: trajId, startStepIndex: prev } },
{ method: 'GetCascadeTrajectory', params: { googleAgentId: agentId, trajectoryId: trajId } }, { method: 'GetCascadeTrajectory', params: { googleAgentId: agentId, trajectoryId: trajId } },
{ method: 'GetCascadeTrajectorySteps', params: { conversationId: agentId, trajectoryId: trajId } },
]; ];
let stepsResult = null; let stepsResult = null;
for (const attempt of attempts) { for (const attempt of attempts) {
@@ -350,18 +365,19 @@ function activate(context) {
} }
} }
else { else {
// All attempts failed — try writing the summary as a fallback // Fallback: relay summary text
const summary = latest.summary || ''; const summaryKey = key + '_summary';
if (summary && summary !== lastStepIndex[key + '_summary']) { if (summary && summary !== lastStepIndex[summaryKey]) {
writeChatSnapshot(`[AI 대화 요약]\n\n${summary}\n\n(step ${prev}${stepIdx})`); writeChatSnapshot(`[AI 응답 감지]\n\n**${summary}**\n\n(step ${prev}${stepIdx})`);
lastStepIndex[key + '_summary'] = summary; lastStepIndex[summaryKey] = summary;
console.log(`Gravity Bridge: [LS] relayed summary fallback: ${summary.substring(0, 100)}`); console.log(`Gravity Bridge: [LS] relayed summary: "${summary.substring(0, 80)}"`);
} }
pollFailCount++; pollFailCount++;
} }
lastStepIndex[key] = stepIdx; lastStepIndex[key] = stepIdx;
} }
} }
}
catch (e) { catch (e) {
console.log(`Gravity Bridge: [LS poll] error: ${e}`); console.log(`Gravity Bridge: [LS poll] error: ${e}`);
} }

File diff suppressed because one or more lines are too long

View File

@@ -264,10 +264,12 @@ export function activate(context: vscode.ExtensionContext) {
} }
let pollFailCount = 0; let pollFailCount = 0;
let pollCount = 0;
async function pollConversations() { async function pollConversations() {
if (!lsPort) { return; } if (!lsPort) { return; }
if (pollFailCount > 3) { return; } // stop after repeated failures if (pollFailCount > 10) { return; } // stop after repeated failures
pollCount++;
try { try {
// Use getDiagnostics to get cascade-level conversation IDs // Use getDiagnostics to get cascade-level conversation IDs
const diag: any = await vscode.commands.executeCommand('antigravity.getDiagnostics'); const diag: any = await vscode.commands.executeCommand('antigravity.getDiagnostics');
@@ -279,37 +281,50 @@ export function activate(context: vscode.ExtensionContext) {
const isFirstPoll = Object.keys(lastStepIndex).length === 0; const isFirstPoll = Object.keys(lastStepIndex).length === 0;
if (isFirstPoll) { if (isFirstPoll) {
console.log(`Gravity Bridge: [LS] ${trajectories.length} recent trajectories from getDiagnostics`); console.log(`Gravity Bridge: [LS] ${trajectories.length} trajectories from getDiagnostics`);
const latest = trajectories[trajectories.length - 1];
console.log(`Gravity Bridge: [LS] latest: ${JSON.stringify(latest).substring(0, 400)}`);
} }
// Check the most recent trajectory for step count changes // Periodic debug every ~1 min (12 * 5s)
const latest = trajectories[trajectories.length - 1]; if (pollCount % 12 === 0) {
const agentId = latest.googleAgentId || ''; const summary = trajectories.map((t: any) => {
const trajId = latest.trajectoryId || ''; const id = (t.googleAgentId || '').substring(0, 8);
const stepIdx = latest.lastStepIndex ?? 0; return `${id}:s${t.lastStepIndex ?? '?'}`;
}).join(', ');
console.log(`Gravity Bridge: [LS] poll#${pollCount}${trajectories.length} trajs: [${summary}]`);
}
if (!agentId && !trajId) { return; } // Check ALL trajectories for step count changes
for (const traj of trajectories) {
const agentId = traj.googleAgentId || '';
const trajId = traj.trajectoryId || '';
const stepIdx = traj.lastStepIndex ?? 0;
const summary = traj.summary || '';
if (!agentId && !trajId) { continue; }
const key = agentId || trajId; const key = agentId || trajId;
const prev = lastStepIndex[key]; const prev = lastStepIndex[key];
if (prev === undefined) { if (prev === undefined) {
// First poll — initialize // First time seeing this trajectory — initialize
lastStepIndex[key] = stepIdx; lastStepIndex[key] = stepIdx;
console.log(`Gravity Bridge: [LS] initialized ${key.substring(0, 8)} at step ${stepIdx}`); if (isFirstPoll) {
return; console.log(`Gravity Bridge: [LS] init ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 30)}"`);
} else {
// New trajectory appeared after first poll = new conversation!
console.log(`Gravity Bridge: [LS] NEW trajectory ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 40)}"`);
}
continue;
} }
if (stepIdx > prev) { if (stepIdx > prev) {
// New steps detected! Try to fetch them // New steps detected!
console.log(`Gravity Bridge: [LS] ${key.substring(0, 8)} new steps: ${prev}${stepIdx}`); console.log(`Gravity Bridge: [LS] ${key.substring(0, 8)} steps: ${prev}${stepIdx} "${summary.substring(0, 40)}"`);
// Try RPC to get full step text
const attempts = [ const attempts = [
{ method: 'GetCascadeTrajectorySteps', params: { googleAgentId: agentId, trajectoryId: trajId, startStepIndex: prev } }, { method: 'GetCascadeTrajectorySteps', params: { googleAgentId: agentId, trajectoryId: trajId, startStepIndex: prev } },
{ method: 'GetCascadeTrajectory', params: { googleAgentId: agentId, trajectoryId: trajId } }, { method: 'GetCascadeTrajectory', params: { googleAgentId: agentId, trajectoryId: trajId } },
{ method: 'GetCascadeTrajectorySteps', params: { conversationId: agentId, trajectoryId: trajId } },
]; ];
let stepsResult: any = null; let stepsResult: any = null;
@@ -332,18 +347,19 @@ export function activate(context: vscode.ExtensionContext) {
extractAndRelaySteps(newSteps); extractAndRelaySteps(newSteps);
} }
} else { } else {
// All attempts failed — try writing the summary as a fallback // Fallback: relay summary text
const summary = latest.summary || ''; const summaryKey = key + '_summary';
if (summary && summary !== lastStepIndex[key + '_summary']) { if (summary && summary !== lastStepIndex[summaryKey]) {
writeChatSnapshot(`[AI 대화 요약]\n\n${summary}\n\n(step ${prev}${stepIdx})`); writeChatSnapshot(`[AI 응답 감지]\n\n**${summary}**\n\n(step ${prev}${stepIdx})`);
lastStepIndex[key + '_summary'] = summary; lastStepIndex[summaryKey] = summary;
console.log(`Gravity Bridge: [LS] relayed summary fallback: ${summary.substring(0, 100)}`); console.log(`Gravity Bridge: [LS] relayed summary: "${summary.substring(0, 80)}"`);
} }
pollFailCount++; pollFailCount++;
} }
lastStepIndex[key] = stepIdx; lastStepIndex[key] = stepIdx;
} }
}
} catch (e) { } catch (e) {
console.log(`Gravity Bridge: [LS poll] error: ${e}`); console.log(`Gravity Bridge: [LS poll] error: ${e}`);
} }
@@ -351,6 +367,7 @@ export function activate(context: vscode.ExtensionContext) {
function extractAndRelaySteps(steps: any[]) { function extractAndRelaySteps(steps: any[]) {
const messages: string[] = []; const messages: string[] = [];