Skip to content

Commit 54d1ef1

Browse files
DOsingaDouwe Osingajamadeo
committed
The client is not the source of truth (#7438)
Co-authored-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Jack Amadeo <jackamadeo@block.xyz>
1 parent e98232e commit 54d1ef1

4 files changed

Lines changed: 15 additions & 8 deletions

File tree

crates/goose-server/src/routes/reply.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ fn track_tool_telemetry(content: &MessageContent, all_messages: &[Message]) {
7979
#[derive(Debug, Deserialize, Serialize, utoipa::ToSchema)]
8080
pub struct ChatRequest {
8181
user_message: Message,
82+
/// Override the server's conversation history. Only use this when you need absolute control
83+
/// over the conversation state (e.g., administrative tools). For normal operations, the server
84+
/// is the source of truth - use truncate/fork endpoints to modify conversation history instead.
8285
#[serde(default)]
83-
conversation_so_far: Option<Vec<Message>>,
86+
override_conversation: Option<Vec<Message>>,
8487
session_id: String,
8588
recipe_name: Option<String>,
8689
recipe_version: Option<String>,
@@ -240,7 +243,7 @@ pub async fn reply(
240243
let cancel_token = CancellationToken::new();
241244

242245
let user_message = request.user_message;
243-
let conversation_so_far = request.conversation_so_far;
246+
let override_conversation = request.override_conversation;
244247

245248
let task_cancel = cancel_token.clone();
246249
let task_tx = tx.clone();
@@ -285,7 +288,7 @@ pub async fn reply(
285288
retry_config: None,
286289
};
287290

288-
let mut all_messages = match conversation_so_far {
291+
let mut all_messages = match override_conversation {
289292
Some(history) => {
290293
let conv = Conversation::new_unvalidated(history);
291294
if let Err(e) = state
@@ -489,7 +492,7 @@ mod tests {
489492
.body(Body::from(
490493
serde_json::to_string(&ChatRequest {
491494
user_message: Message::user().with_text("test message"),
492-
conversation_so_far: None,
495+
override_conversation: None,
493496
session_id: "test-session".to_string(),
494497
recipe_name: None,
495498
recipe_version: None,

ui/desktop/openapi.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3898,11 +3898,12 @@
38983898
"session_id"
38993899
],
39003900
"properties": {
3901-
"conversation_so_far": {
3901+
"override_conversation": {
39023902
"type": "array",
39033903
"items": {
39043904
"$ref": "#/components/schemas/Message"
39053905
},
3906+
"description": "Override the server's conversation history. Only use this when you need absolute control\nover the conversation state (e.g., administrative tools). For normal operations, the server\nis the source of truth - use truncate/fork endpoints to modify conversation history instead.",
39063907
"nullable": true
39073908
},
39083909
"recipe_name": {

ui/desktop/src/api/types.gen.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ export type CallToolResponse = {
6060
};
6161

6262
export type ChatRequest = {
63-
conversation_so_far?: Array<Message> | null;
63+
/**
64+
* Override the server's conversation history. Only use this when you need absolute control
65+
* over the conversation state (e.g., administrative tools). For normal operations, the server
66+
* is the source of truth - use truncate/fork endpoints to modify conversation history instead.
67+
*/
68+
override_conversation?: Array<Message> | null;
6469
recipe_name?: string | null;
6570
recipe_version?: string | null;
6671
session_id: string;

ui/desktop/src/hooks/useChatStream.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@ export function useChatStream({
590590
body: {
591591
session_id: sessionId,
592592
user_message: newMessage,
593-
...(hasExistingMessages && { conversation_so_far: currentState.messages }),
594593
},
595594
throwOnError: true,
596595
signal: abortControllerRef.current.signal,
@@ -771,7 +770,6 @@ export function useChatStream({
771770
body: {
772771
session_id: targetSessionId,
773772
user_message: updatedUserMessage,
774-
conversation_so_far: truncatedMessages,
775773
},
776774
throwOnError: true,
777775
signal: abortControllerRef.current.signal,

0 commit comments

Comments
 (0)