agent: Fix unnecessary "tool result too long" (#30798)
Release Notes: - N/A
This commit is contained in:
parent
0f17e82154
commit
cc3a28a8e8
1 changed files with 6 additions and 5 deletions
|
@ -425,16 +425,17 @@ impl ToolUseState {
|
||||||
|
|
||||||
let content = match tool_result {
|
let content = match tool_result {
|
||||||
ToolResultContent::Text(text) => {
|
ToolResultContent::Text(text) => {
|
||||||
let truncated = truncate_lines_to_byte_limit(&text, tool_output_limit);
|
let text = if text.len() < tool_output_limit {
|
||||||
|
text
|
||||||
LanguageModelToolResultContent::Text(
|
} else {
|
||||||
|
let truncated = truncate_lines_to_byte_limit(&text, tool_output_limit);
|
||||||
format!(
|
format!(
|
||||||
"Tool result too long. The first {} bytes:\n\n{}",
|
"Tool result too long. The first {} bytes:\n\n{}",
|
||||||
truncated.len(),
|
truncated.len(),
|
||||||
truncated
|
truncated
|
||||||
)
|
)
|
||||||
.into(),
|
};
|
||||||
)
|
LanguageModelToolResultContent::Text(text.into())
|
||||||
}
|
}
|
||||||
ToolResultContent::Image(language_model_image) => {
|
ToolResultContent::Image(language_model_image) => {
|
||||||
if language_model_image.estimate_tokens() < tool_output_limit {
|
if language_model_image.estimate_tokens() < tool_output_limit {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue