mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-24 10:12:44 +00:00
fix(server): accept fractional PASEO_CLAUDE_REPLAY_BUDGET_MB values
parseInt read 0.5 as 0, so a fractional budget silently fell back to the 256 MB default — the opposite of what a small-host operator asked for. Parse the value as a float and pin the behavior with a regression test.
This commit is contained in:
@@ -489,6 +489,28 @@ describe("ClaudeAgentSession persisted subagent replay", () => {
|
||||
expect(descriptors.map((descriptor) => descriptor.id)).toContain(TOOL_USE_ID);
|
||||
});
|
||||
|
||||
test("honors a fractional replay budget instead of rounding it up to the default", async () => {
|
||||
// 0.5 MB is 524,288 bytes; parseInt would read it as 0 and silently fall back to 256 MB.
|
||||
vi.stubEnv("PASEO_CLAUDE_REPLAY_BUDGET_MB", "0.5");
|
||||
const bulkEntry = JSON.stringify({
|
||||
type: "user",
|
||||
isSidechain: true,
|
||||
agentId: AGENT_ID,
|
||||
sessionId: "replay-session",
|
||||
timestamp: "2026-07-26T06:27:55.000Z",
|
||||
message: { role: "user", content: "x".repeat(600 * 1024) },
|
||||
});
|
||||
writeSession({
|
||||
parentLines: [taskToolUse(), taskToolResult()],
|
||||
meta: JSON.stringify({ toolUseId: TOOL_USE_ID }),
|
||||
sidechainLines: [sidechainEntry(), bulkEntry],
|
||||
});
|
||||
|
||||
const events = await replayEvents();
|
||||
|
||||
expect(events.filter((event) => event.type === "provider_subagent")).toEqual([]);
|
||||
});
|
||||
|
||||
test("replays the parent unchanged, matching the same session without subagent transcripts", async () => {
|
||||
// The #5820 reporter's own technique: moving the subagent transcripts away leaves the parent
|
||||
// loading fine. The over-budget skip has to be indistinguishable from that state.
|
||||
|
||||
@@ -5932,7 +5932,7 @@ const CLAUDE_SUBAGENT_META_FILE = /^agent-(.+)\.meta\.json$/;
|
||||
const DEFAULT_CLAUDE_REPLAY_BUDGET_BYTES = 256 * 1024 * 1024;
|
||||
|
||||
function claudeReplayBudgetBytes(): number {
|
||||
const megabytes = Number.parseInt(process.env.PASEO_CLAUDE_REPLAY_BUDGET_MB ?? "", 10);
|
||||
const megabytes = Number.parseFloat(process.env.PASEO_CLAUDE_REPLAY_BUDGET_MB ?? "");
|
||||
return Number.isFinite(megabytes) && megabytes > 0
|
||||
? megabytes * 1024 * 1024
|
||||
: DEFAULT_CLAUDE_REPLAY_BUDGET_BYTES;
|
||||
|
||||
Reference in New Issue
Block a user