Skip to content

Commit 2222626

Browse files
brandonskiserKonippi
authored andcommitted
fix(chat): add error log if we receive a response timeout message
1 parent ef189f7 commit 2222626

File tree

1 file changed

+9
-1
lines changed
  • crates/q_cli/src/cli/chat

1 file changed

+9
-1
lines changed

crates/q_cli/src/cli/chat/mod.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ const HELP_TEXT: &str = color_print::cstr! {"
160160
161161
"};
162162

163+
const RESPONSE_TIMEOUT_CONTENT: &str = "Response timed out - message took too long to generate";
164+
163165
pub async fn chat(
164166
input: Option<String>,
165167
no_interactive: bool,
@@ -1509,6 +1511,7 @@ where
15091511
}
15101512

15111513
async fn handle_response(&mut self, response: SendMessageOutput) -> Result<ChatState, ChatError> {
1514+
let request_id = response.request_id().map(|s| s.to_string());
15121515
let mut buf = String::new();
15131516
let mut offset = 0;
15141517
let mut ended = false;
@@ -1545,6 +1548,11 @@ where
15451548
tool_name_being_recvd = None;
15461549
},
15471550
parser::ResponseEvent::EndStream { message } => {
1551+
// This log is attempting to help debug instances where users encounter
1552+
// the response timeout message.
1553+
if message.content == RESPONSE_TIMEOUT_CONTENT {
1554+
error!(?request_id, ?message, "Encountered an unexpected model response");
1555+
}
15481556
self.conversation_state.push_assistant_message(message);
15491557
ended = true;
15501558
},
@@ -1573,7 +1581,7 @@ where
15731581
self.conversation_state
15741582
.push_assistant_message(AssistantResponseMessage {
15751583
message_id: None,
1576-
content: "Response timed out - message took too long to generate".to_string(),
1584+
content: RESPONSE_TIMEOUT_CONTENT.to_string(),
15771585
tool_uses: None,
15781586
});
15791587
self.conversation_state

0 commit comments

Comments
 (0)