Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix: a cursor set aside no longer sizes the fallback window (review fix-check)
garrytane05b69dfdace
diff --git a/src/core/ops/get-page-body.ts b/src/core/ops/get-page-body.tsindex c99481e79d..23337d3883 100644--- a/src/core/ops/get-page-body.ts+++ b/src/core/ops/get-page-body.ts@@ -605,7 +605,9 @@ export async function readPartialBody(ctx: OperationContext, input: PartialReadIreturn around.window;};const cap = await resultByteCap({ remote: ctx.remote, transport: ctx.transport, engine: ctx.engine, config: ctx.config });- let maxBytes = await windowBudget(ctx, req.maxBytes ?? (sel?.kind === 'cursor' ? decodeCursor(sel.raw)?.max_bytes : undefined), DEFAULT_WINDOW_BYTES);+ const startCursor = sel?.kind === 'cursor' ? decodeCursor(sel.raw) : null;+ const cursorReads = startCursor !== null && startCursor.page_id === page.id && startCursor.view === req.view && startCursor.revision === revision;+ let maxBytes = await windowBudget(ctx, req.maxBytes ?? (cursorReads ? startCursor.max_bytes : undefined), DEFAULT_WINDOW_BYTES);for (let attempt = 0; ; attempt++) {const win = await select(maxBytes);if (!win) return confirmed({ ...out, truncated: true });diff --git a/test/get-page-body-modes.test.ts b/test/get-page-body-modes.test.tsindex b1934a49f9..1a1c614c26 100644--- a/test/get-page-body-modes.test.ts+++ b/test/get-page-body-modes.test.ts@@ -207,6 +207,15 @@ describe('several window selectors (GBRA-280)', () => {expect([r.body, r.window.line_start, r.window_selector.applied]).toEqual(['window', 100, 'lines']);});+ test('a cursor set aside does not size the window the next selector reads', async () => {+ await put('logs/sel-size', conversation(6000));+ const tiny = (await get(ctx(), { slug: 'logs/big', body: 'window', max_bytes: 50 })).next_cursor;+ const r = await get(ctx(), { slug: 'logs/sel-size', cursor: tiny, lines: { from: 7, count: 20 } });+ const alone = await get(ctx(), { slug: 'logs/sel-size', lines: { from: 7, count: 20 } });+ expect([r.window_selector.applied, r.window]).toEqual(['lines', alone.window]);+ expect(r.next_cursor ? decodeCursor(r.next_cursor)!.max_bytes : null).toBe(alone.next_cursor ? decodeCursor(alone.next_cursor)!.max_bytes : null);+ });+test('a set-aside include_content or content_only says the window is not the page and how to edit it', async () => {const r = await get(ctx(), { slug: 'logs/big', include_content: true, lines: { from: 100, count: 3 } });expect(r.window_selector.note).toBe("Read the lines window; ignored include_content. This window is not the page's content: put_page with it would replace the whole page with this window, so edit through edit_page with edit_target, or read with include_content alone. get_page reads one window: cursor, then around_chunk_id, then lines, then bytes.");