Fix bulk of remaining issues with generalist profile (#26073)

This commit is contained in:
joshualitt
2026-05-01 15:04:39 -07:00
committed by GitHub
parent 408afd3c5a
commit de8fdcfa16
52 changed files with 2133 additions and 1364 deletions
@@ -3,6 +3,14 @@
exports[`System Lifecycle Golden Tests > Scenario 1: Organic Growth with Huge Tool Output & Images 1`] = `
{
"finalProjection": [
{
"parts": [
{
"text": "[Continuing from previous AI thoughts...]",
},
],
"role": "user",
},
{
"parts": [
{
@@ -27,31 +35,39 @@ exports[`System Lifecycle Golden Tests > Scenario 1: Organic Growth with Huge To
],
"role": "model",
},
{
"parts": [
{
"text": "Please continue.",
},
],
"role": "user",
},
],
"tokenTrajectory": [
{
"tokensAfterBackground": 6,
"tokensBeforeBackground": 6,
"tokensAfterBackground": 17,
"tokensBeforeBackground": 17,
"turnIndex": 0,
},
{
"tokensAfterBackground": 11,
"tokensBeforeBackground": 11,
"tokensAfterBackground": 34,
"tokensBeforeBackground": 34,
"turnIndex": 1,
},
{
"tokensAfterBackground": 458,
"tokensBeforeBackground": 20170,
"tokensAfterBackground": 327,
"tokensBeforeBackground": 20172,
"turnIndex": 2,
},
{
"tokensAfterBackground": 61,
"tokensBeforeBackground": 3017,
"tokensAfterBackground": 93,
"tokensBeforeBackground": 3037,
"turnIndex": 3,
},
{
"tokensAfterBackground": 10,
"tokensBeforeBackground": 10,
"tokensAfterBackground": 27,
"tokensBeforeBackground": 27,
"turnIndex": 4,
},
],
@@ -93,16 +109,24 @@ exports[`System Lifecycle Golden Tests > Scenario 2: Under Budget (No Modificati
],
"role": "model",
},
{
"parts": [
{
"text": "Please continue.",
},
],
"role": "user",
},
],
"tokenTrajectory": [
{
"tokensAfterBackground": 6,
"tokensBeforeBackground": 6,
"tokensAfterBackground": 17,
"tokensBeforeBackground": 17,
"turnIndex": 0,
},
{
"tokensAfterBackground": 11,
"tokensBeforeBackground": 11,
"tokensAfterBackground": 34,
"tokensBeforeBackground": 34,
"turnIndex": 1,
},
],
@@ -160,21 +184,29 @@ exports[`System Lifecycle Golden Tests > Scenario 3: Async-Driven Background GC
],
"role": "model",
},
{
"parts": [
{
"text": "Please continue.",
},
],
"role": "user",
},
],
"tokenTrajectory": [
{
"tokensAfterBackground": 25,
"tokensBeforeBackground": 25,
"tokensAfterBackground": 42,
"tokensBeforeBackground": 42,
"turnIndex": 0,
},
{
"tokensAfterBackground": 49,
"tokensBeforeBackground": 49,
"tokensAfterBackground": 84,
"tokensBeforeBackground": 84,
"turnIndex": 1,
},
{
"tokensAfterBackground": 73,
"tokensBeforeBackground": 73,
"tokensAfterBackground": 126,
"tokensBeforeBackground": 126,
"turnIndex": 2,
},
],
@@ -18,14 +18,24 @@ import { createStateSnapshotAsyncProcessor } from '../processors/stateSnapshotAs
expect.addSnapshotSerializer({
test: (val) =>
typeof val === 'string' &&
(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i.test(
val,
) ||
/^\/tmp\/sim/.test(val)), // Mask temp directories and UUIDs
print: (val) =>
typeof val === 'string' && /^\/tmp\/sim/.test(val)
? '"<MOCKED_DIR>"'
: '"<UUID>"',
/[\\/]tmp[\\/]sim/.test(val)),
print: (val) => {
if (typeof val !== 'string') return `"${val}"`;
let scrubbed = val
.replace(
/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,
'<UUID>',
)
.replace(/[\\/]tmp[\\/]sim[^\s"'\]]*/g, '<MOCKED_DIR>');
// Also scrub timestamps in filenames like blob_1234567890_...
scrubbed = scrubbed.replace(/blob_\d+_/g, 'blob_<TIMESTAMP>_');
return `"${scrubbed}"`;
},
});
describe('System Lifecycle Golden Tests', () => {
@@ -43,6 +53,7 @@ describe('System Lifecycle Golden Tests', () => {
});
const getAggressiveConfig = (): ContextProfile => ({
name: 'Aggressive Test',
config: {
budget: { maxTokens: 1000, retainedTokens: 500 }, // Extremely tight limits
},
@@ -170,6 +181,7 @@ describe('System Lifecycle Golden Tests', () => {
it('Scenario 2: Under Budget (No Modifications)', async () => {
const generousConfig: ContextProfile = {
name: 'Generous Config',
config: {
budget: { maxTokens: 100000, retainedTokens: 50000 },
},
@@ -202,6 +214,7 @@ describe('System Lifecycle Golden Tests', () => {
it('Scenario 3: Async-Driven Background GC', async () => {
const gcConfig: ContextProfile = {
name: 'GC Test Config',
config: {
budget: { maxTokens: 200, retainedTokens: 100 },
},
@@ -148,7 +148,8 @@ export class SimulationHarness {
}
async getGoldenState() {
const finalProjection = await this.contextManager.renderHistory();
const { history: finalProjection } =
await this.contextManager.renderHistory();
return {
tokenTrajectory: this.tokenTrajectory,
finalProjection,