From a9167280acf070e61d54695f111fde9b9204bbcc Mon Sep 17 00:00:00 2001 From: imccyu <276526105+imccyu@users.noreply.github.com> Date: Thu, 6 Aug 2026 03:30:16 +0800 Subject: [PATCH] fix(fixture): restore the extended-block pricing fallback The client graph's ContentBlock narrows to the base four members, but fixture turns carry merge-extended blocks at runtime, so removing the JSON fallback crashed pricing on them. Keep the fallback and suppress the narrowing-based lint finding with the reason inline. --- packages/client/connection/src/client/fixture.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/client/connection/src/client/fixture.ts b/packages/client/connection/src/client/fixture.ts index 8528cf0184..4fdbbc7873 100644 --- a/packages/client/connection/src/client/fixture.ts +++ b/packages/client/connection/src/client/fixture.ts @@ -846,9 +846,14 @@ function estimateFixtureContent(blocks: readonly ContentBlock[]): number { if (block.type === 'tool-call') { return tokens + densityPrice(block.name) + densityPrice(block.arguments) + BLOCK_OVERHEAD } - // Fixture-authored content is the closed base vocabulary, so tool-result - // is the only remaining shape — no merge-extension fallback can occur. - return tokens + estimateFixtureContent(block.content) + BLOCK_OVERHEAD + // ContentBlockMap is merge-extensible: this client graph sees only the + // base four members, but fixture turns do carry extended blocks at + // runtime, so the structural JSON fallback below is live code. + // oxlint-disable-next-line typescript/no-unnecessary-condition -- the type collapses without the out-of-graph merges (see above). + if (block.type === 'tool-result') { + return tokens + estimateFixtureContent(block.content) + BLOCK_OVERHEAD + } + return tokens + densityPrice(JSON.stringify(block)) + BLOCK_OVERHEAD }, 0) }