Skip to content

Fix read_cell_output incorrectly reporting all outputs as too large#5093

Open
oded-ist wants to merge 1 commit intomicrosoft:mainfrom
oded-ist:fix/notebook-tool-output-too-long
Open

Fix read_cell_output incorrectly reporting all outputs as too large#5093
oded-ist wants to merge 1 commit intomicrosoft:mainfrom
oded-ist:fix/notebook-tool-output-too-long

Conversation

@oded-ist
Copy link
Copy Markdown

Two related issues caused even tiny notebook cell outputs (e.g. 5 bytes) to be replaced with "Output is too large to be used as context".

  1. Inverted size check in RunNotebookCellOutput: getCharLimit converts tokens to chars (×4), but it was applied to the byteLength side and compared against a token count. Compare byteLength against getCharLimit(tokenBudget / sizeLimitRatio) instead — the threshold was 16× too small.

  2. Remove ReadCellOutput from toolsCalledInParallel. Tools in that set are invoked eagerly with a sentinel { tokenBudget: 1 } sizing on the premise that they don't consume sizing info. RunNotebookCellOutput does — it gates output on sizing.tokenBudget — so the sentinel made every non-empty output trip the size check. Letting it use the normal lazy path gives it the endpoint's real prompt budget.

Two related issues caused even tiny notebook cell outputs (e.g. 5 bytes)
to be replaced with "Output is too large to be used as context".

1. Inverted size check in `RunNotebookCellOutput`: `getCharLimit` converts
   tokens to chars (×4), but it was applied to the byteLength side and
   compared against a token count. Compare byteLength against
   getCharLimit(tokenBudget / sizeLimitRatio) instead — the threshold was
   16× too small.

2. Remove `ReadCellOutput` from `toolsCalledInParallel`. Tools in that set
   are invoked eagerly with a sentinel `{ tokenBudget: 1 }` sizing on the
   premise that they don't consume sizing info. `RunNotebookCellOutput`
   does — it gates output on `sizing.tokenBudget` — so the sentinel made
   every non-empty output trip the size check. Letting it use the normal
   lazy path gives it the endpoint's real prompt budget.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant