mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
fix: preserve thinking content for provider context (#9314)
Signed-off-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Jack Amadeo <jackamadeo@squareup.com>
This commit is contained in:
@@ -377,7 +377,13 @@ impl MessageContent {
|
||||
metadata: res.metadata.clone(),
|
||||
}))
|
||||
}
|
||||
MessageContent::Thinking(_) | MessageContent::RedactedThinking(_) => None,
|
||||
MessageContent::Thinking(_) | MessageContent::RedactedThinking(_) => {
|
||||
if audience == Role::Assistant {
|
||||
Some(self.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => Some(self.clone()),
|
||||
}
|
||||
}
|
||||
@@ -1227,6 +1233,25 @@ mod tests {
|
||||
assert!(thinking.signature.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_agent_visible_content_preserves_thinking_for_provider() {
|
||||
let message = Message::assistant()
|
||||
.with_thinking("internal reasoning", "sig")
|
||||
.with_redacted_thinking("redacted")
|
||||
.with_text("final answer");
|
||||
|
||||
let provider_message = message.agent_visible_content();
|
||||
assert_eq!(provider_message.content.len(), 3);
|
||||
assert!(matches!(
|
||||
provider_message.content[0],
|
||||
MessageContent::Thinking(_)
|
||||
));
|
||||
assert!(matches!(
|
||||
provider_message.content[1],
|
||||
MessageContent::RedactedThinking(_)
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization_drops_invalid_reasoning_blocks() {
|
||||
let json = serde_json::json!({
|
||||
|
||||
Reference in New Issue
Block a user