agent: Do not add <using_tool> placeholder (#29194)
Our provider code in `language_models` filters out messages for which `LanguageModelRequestMessage::contents_empty` returns `false`. This doesn't seem wrong by itself, but `contents_empty` was returning `false` for messages whose first segment didn't contain non-whitespace text even if they contained other non-empty segments. This caused requests to fail when a message with a tool call didn't contain any preceding text. Release Notes: - N/A
This commit is contained in:
@@ -38,7 +38,7 @@ use crate::thread_store::{
|
||||
SerializedMessage, SerializedMessageSegment, SerializedThread, SerializedToolResult,
|
||||
SerializedToolUse, SharedProjectContext,
|
||||
};
|
||||
use crate::tool_use::{PendingToolUse, ToolUse, ToolUseMetadata, ToolUseState, USING_TOOL_MARKER};
|
||||
use crate::tool_use::{PendingToolUse, ToolUse, ToolUseMetadata, ToolUseState};
|
||||
|
||||
#[derive(
|
||||
Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Serialize, Deserialize, JsonSchema,
|
||||
@@ -167,12 +167,9 @@ pub enum MessageSegment {
|
||||
|
||||
impl MessageSegment {
|
||||
pub fn should_display(&self) -> bool {
|
||||
// We add USING_TOOL_MARKER when making a request that includes tool uses
|
||||
// without non-whitespace text around them, and this can cause the model
|
||||
// to mimic the pattern, so we consider those segments not displayable.
|
||||
match self {
|
||||
Self::Text(text) => text.is_empty() || text.trim() == USING_TOOL_MARKER,
|
||||
Self::Thinking { text, .. } => text.is_empty() || text.trim() == USING_TOOL_MARKER,
|
||||
Self::Text(text) => text.is_empty(),
|
||||
Self::Thinking { text, .. } => text.is_empty(),
|
||||
Self::RedactedThinking(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user