Files
memind/scripts/check-goosed-v149-resume.mjs
T
john fe8a5e74d1 fix(goose): tighten memory drift checks and add resume smoke gate
Compare memory userId and candidate deltas during manifest drift checks,
add unit tests for false-positive cases, and verify /agent/resume plus
session history loading against local v1.49.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-08 21:27:14 +08:00

70 lines
2.4 KiB
JavaScript

#!/usr/bin/env node
/**
* Verify v1.49 session history + /agent/resume parity with goose-server 1.41.
*/
import { createV149Client } from './goose-v149-sse.mjs';
const client = createV149Client();
function messageCount(session) {
const conversation = session?.conversation;
if (!conversation) return 0;
if (Array.isArray(conversation.messages)) return conversation.messages.length;
if (Array.isArray(conversation)) return conversation.length;
return Number(session?.message_count ?? session?.messageCount ?? 0);
}
async function main() {
const list = await client.apiJson('/sessions', undefined, { method: 'GET' });
const sessions = list?.sessions ?? [];
const rich = sessions
.slice()
.sort((a, b) => Number(b.message_count ?? b.messageCount ?? 0) - Number(a.message_count ?? a.messageCount ?? 0))
.find((item) => Number(item.message_count ?? item.messageCount ?? 0) > 0);
if (!rich?.id) {
throw new Error('no session with message_count > 0; run check-goosed-v149-provider.mjs first');
}
const sessionId = rich.id;
const detailRes = await client.apiFetch(`/sessions/${sessionId}`, { method: 'GET' });
const detailText = await detailRes.text();
if (!detailRes.ok) {
throw new Error(`GET /sessions/{id} ${detailRes.status}: ${detailText.slice(0, 400)}`);
}
const detail = JSON.parse(detailText);
const beforeCount = messageCount(detail);
if (beforeCount <= 0) {
throw new Error(
`GET /sessions/{id} returned empty conversation for message_count=${rich.message_count ?? rich.messageCount}`,
);
}
const resume = await client.apiJson('/agent/resume', {
session_id: sessionId,
load_model_and_extensions: true,
});
if (!resume?.session?.id) {
throw new Error('POST /agent/resume missing session');
}
const afterCount = messageCount(resume.session);
if (afterCount <= 0) {
throw new Error('POST /agent/resume returned session without conversation history');
}
const restart = await client.apiJson('/agent/restart', { session_id: sessionId });
if (!Array.isArray(restart?.extension_results)) {
throw new Error('POST /agent/restart missing extension_results array');
}
console.log(
`GOOSE_V149_RESUME_OK: session=${sessionId} messages=${afterCount} `
+ `restartExtensions=${restart.extension_results.length}`,
);
}
main().catch((error) => {
console.error(`GOOSE_V149_RESUME_FAIL: ${error.message}`);
process.exit(1);
});