Skip to content

Commit e7fe62a

Browse files
committed
read_file output cap raised to ~256 KB** (64k tokens)
1 parent a2c796c commit e7fe62a

3 files changed

Lines changed: 28 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to Sofos are documented in this file.
44

55
## [Unreleased]
66

7+
### Changed
8+
9+
- **`read_file` output cap raised to ~256 KB** (64k tokens). Previously `read_file` shared the ~64 KB / 16k-token cap with `execute_bash` and `search_code`, which clipped mid-sized source files — generated code, JSON fixtures, long prompt templates — and forced the model into an extra range-reads round trip against the 200-iteration tool-loop budget. `execute_bash` stdout/stderr and `search_code` keep the 16k-token cap, since verbose test output and broad ripgrep patterns benefit from being forced to narrow rather than handing the model noise.
10+
11+
### Fixed
12+
13+
- Prompt glyph (> or :) now correctly reflects the normal/safe modes.
14+
715
## [0.2.2] - 2026-04-21
816

917
### Security

src/tools/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use tool_name::ToolName;
2222

2323
use crate::tools::types::get_read_only_tools;
2424
use crate::tools::utils::{
25-
MAX_DIFF_TOKENS, MAX_MCP_IMAGE_BYTES, MAX_MCP_IMAGE_COUNT, MAX_MCP_OUTPUT_TOKENS,
26-
MAX_PATH_LIST_TOKENS, MAX_TOOL_OUTPUT_TOKENS, TruncationKind, confirm_destructive,
25+
MAX_DIFF_TOKENS, MAX_FILE_READ_TOKENS, MAX_MCP_IMAGE_BYTES, MAX_MCP_IMAGE_COUNT,
26+
MAX_MCP_OUTPUT_TOKENS, MAX_PATH_LIST_TOKENS, TruncationKind, confirm_destructive,
2727
is_absolute_or_tilde, truncate_for_context,
2828
};
2929
pub use types::{add_code_search_tool, get_all_tools, get_all_tools_with_morph};
@@ -659,7 +659,7 @@ impl ToolExecutor {
659659
.read_file_with_outside_access(&resolved.canonical_str)?
660660
};
661661
let content =
662-
truncate_for_context(&raw, MAX_TOOL_OUTPUT_TOKENS, TruncationKind::File);
662+
truncate_for_context(&raw, MAX_FILE_READ_TOKENS, TruncationKind::File);
663663
Ok(format!("File content of '{}':\n\n{}", path, content))
664664
}
665665
ToolName::WriteFile => {

src/tools/utils.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,25 @@ use std::io;
33
use std::io::Write;
44
use std::sync::OnceLock;
55

6-
/// Maximum tokens (≈ chars / 4, ≈ 64 KB) a single tool call is allowed
7-
/// to return before [`truncate_for_context`] clips it with an informational
8-
/// suffix. Keeps a single large bash output or file read from monopolising
9-
/// the model's context window.
6+
/// Maximum tokens (≈ chars / 4, ≈ 64 KB) returned from `execute_bash`
7+
/// (stdout / stderr) and `search_code` (ripgrep output) before
8+
/// [`truncate_for_context`] clips with an informational suffix. Verbose
9+
/// test runs and broad regex searches spiral quickly; capping here forces
10+
/// the model to narrow the query or redirect to a file rather than drown
11+
/// the context in noise. `read_file` uses a separate, larger cap —
12+
/// see [`MAX_FILE_READ_TOKENS`].
1013
pub const MAX_TOOL_OUTPUT_TOKENS: usize = 16_000;
1114

15+
/// Larger cap (≈ 256 KB) for `read_file` output. A single mid-sized
16+
/// source file — generated code, JSON fixtures, long prompt templates —
17+
/// routinely exceeds the 16 KB bash/search budget, and clipping it
18+
/// forces the model into a range-reads round trip against the
19+
/// 200-iteration budget. Files are structured content the model
20+
/// typically needs to reason about in full, so the tradeoff favours a
21+
/// bigger budget here than for bash noise. Still far below OpenAI's
22+
/// 10 MB per-tool-output ceiling.
23+
pub const MAX_FILE_READ_TOKENS: usize = 64_000;
24+
1225
/// Separate, more generous cap for path-list tools (`list_directory`,
1326
/// `glob_files`). Filenames are short and the model often needs to see
1427
/// the full listing to locate a specific file, so we apply roughly an

0 commit comments

Comments
 (0)