| 1881 | const MAX_TOOL_RESULT_CHARS: usize = 3000; |
| 1882 | |
| 1883 | fn truncate_tool_result(output: &str) -> String { |
| 1884 | if output.len() <= MAX_TOOL_RESULT_CHARS { |
| 1885 | return output.to_string(); |
| 1886 | } |
| 1887 | |
| 1888 | // Keep first and last portions for context |
| 1889 | let head_size = MAX_TOOL_RESULT_CHARS * 2 / 3; // ~2000 chars from start |
| 1890 | let tail_size = MAX_TOOL_RESULT_CHARS / 3; // ~1000 chars from end |
| 1891 | |
| 1892 | let head = &output[..head_size]; |
| 1893 | let tail = &output[output.len() - tail_size..]; |
| 1894 | let omitted = output.len() - head_size - tail_size; |
| 1895 | |
| 1896 | format!( |
| 1897 | "{}\n\n… [{} chars omitted] …\n\n{}", |
| 1898 | head, omitted, tail |
| 1899 | ) |
| 1900 | } |
| 1901 | |
| 1902 | /// Check if the user's message contains keywords that need the full PREVIEW_GUIDE |
| 1903 | fn needs_full_preview_guide(task: &str) -> bool { |