Skip to content

Fix read_cell_output incorrectly reporting all outputs as too large#318148

Open
oded-ist wants to merge 2 commits into
microsoft:mainfrom
oded-ist:fix-read-cell-output
Open

Fix read_cell_output incorrectly reporting all outputs as too large#318148
oded-ist wants to merge 2 commits into
microsoft:mainfrom
oded-ist:fix-read-cell-output

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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adjusts notebook cell output sizing logic to better align with token-budget-based limits and changes which tools are eligible for parallel execution in tool-calling.

Changes:

  • Updates large-output detection to compute limits from the token budget (instead of passing byteLength into getCharLimit).
  • Removes ToolName.ReadCellOutput from the set of tools eligible to run in parallel.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
extensions/copilot/src/extension/tools/node/runNotebookCellTool.tsx Reworks the “output too large” checks to compute a limit from token budget and compare against output size.
extensions/copilot/src/extension/prompts/node/panel/toolCalling.tsx Updates tool parallelization configuration by removing ReadCellOutput from the parallel set.
Comments suppressed due to low confidence (1)

extensions/copilot/src/extension/prompts/node/panel/toolCalling.tsx:1

  • Removing ToolName.ReadCellOutput from toolsCalledInParallel can increase latency when multiple tools are invoked together (since it will no longer be parallelized). If there’s a correctness/sequencing requirement that forces it to run serially, it would help maintainability to add an inline comment explaining the dependency; otherwise consider keeping it in the parallel set.
/*---------------------------------------------------------------------------------------------

Comment thread extensions/copilot/src/extension/tools/node/runNotebookCellTool.tsx
Comment thread extensions/copilot/src/extension/tools/node/runNotebookCellTool.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants