Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: keep the compaction setting from the server

ogsamrat2f0461b39dab
diff --git a/apps/server/src/omnirush-gateway-broker.test.ts b/apps/server/src/omnirush-gateway-broker.test.ts
index 3f9a43bc..d4068b75 100644
--- a/apps/server/src/omnirush-gateway-broker.test.ts
+++ b/apps/server/src/omnirush-gateway-broker.test.ts
@@ -1518,6 +1518,24 @@ describe("OmniRush gateway broker upload keys, account and integrity", () => {
expect((await make().sessionUploadCapabilities()).local_box).toEqual({ default: "offer", max_turn_bytes: null, backends: null });
});
+ test("the automatic compaction block is passed on, and maxAgeMs asks the server again", async () => {
+ let calls = 0;
+ let block: unknown = { enabled: true, after_turns: 40, min_context_tokens: 0 };
+ const broker = new OmniRushGatewayBroker({
+ credentials,
+ engineToken: "local-engine-token",
+ fetch: async () => { calls += 1; return Response.json({ schema_versions: [2, 3], canonical_trace: true, auto_compact: block }); },
+ });
+ expect((await broker.sessionUploadCapabilities()).auto_compact).toEqual({ enabled: true, after_turns: 40, min_context_tokens: 0 });
+ block = { enabled: false, after_turns: 40 };
+ expect((await broker.sessionUploadCapabilities({ maxAgeMs: 60_000 })).auto_compact?.enabled).toBe(true);
+ expect(calls).toBe(1);
+ expect((await broker.sessionUploadCapabilities({ maxAgeMs: 0 })).auto_compact).toEqual({ enabled: false, after_turns: 40 });
+ expect(calls).toBe(2);
+ block = "on";
+ expect((await broker.sessionUploadCapabilities({ maxAgeMs: 0 })).auto_compact).toBeUndefined();
+ });
+
const credentials = { gatewayUrl: "https://gateway.example/omnirush/v1", accessToken: "access-1", refreshToken: "refresh-1" };
test("uploadSession and uploadSessionFile send the Idempotency-Key they are given", async () => {
diff --git a/apps/server/src/omnirush-gateway-broker.ts b/apps/server/src/omnirush-gateway-broker.ts
index f1180148..a745fc24 100644
--- a/apps/server/src/omnirush-gateway-broker.ts
+++ b/apps/server/src/omnirush-gateway-broker.ts
@@ -1532,6 +1532,10 @@ export class OmniRushGatewayBroker {
// The install log switch, passed on as the server said it (context/install-log.ts reads it).
...(installLog ? { install_log: { enabled: installLog.enabled === true, sample_percent: typeof installLog.sample_percent === "number" ? installLog.sample_percent : 100 } } : {}),
...(isRecord(payload.local_box) ? { local_box: localBoxCapability(payload.local_box) } : {}),
+ // Automatic compaction (session-archive/auto-compact.ts reads it; absent is off).
+ ...(isRecord(payload.auto_compact) && typeof payload.auto_compact.enabled === "boolean" && typeof payload.auto_compact.after_turns === "number"
+ ? { auto_compact: { enabled: payload.auto_compact.enabled, after_turns: payload.auto_compact.after_turns, ...(typeof payload.auto_compact.min_context_tokens === "number" ? { min_context_tokens: payload.auto_compact.min_context_tokens } : {}) } }
+ : {}),
};
} catch {
return null;