Skip to content

Commit 449032d

Browse files
authored
Don't stop turn on errors that Codex is handling (#82)
There are two classes of errors. One, `EventMsg::Error` is a signal that it is the end of the turn. But `EventMsg::StreamError` are errors that are being handled by Codex (like retries) so we should let them through.
1 parent 9d14c8e commit 449032d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/conversation.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,11 @@ impl PromptState {
463463
response_tx.send(Ok(StopReason::EndTurn)).ok();
464464
}
465465
}
466-
EventMsg::Error(ErrorEvent { message })
467-
| EventMsg::StreamError(StreamErrorEvent { message }) => {
468-
error!("Error during turn: {}", message);
466+
EventMsg::StreamError(StreamErrorEvent { message }) => {
467+
error!("Handled error during turn: {}", message);
468+
}
469+
EventMsg::Error(ErrorEvent { message }) => {
470+
error!("Unhandled error during turn: {}", message);
469471
if let Some(response_tx) = self.response_tx.take() {
470472
response_tx.send(Err(Error::internal_error().with_data(message))).ok();
471473
}
@@ -1195,9 +1197,11 @@ impl TaskState {
11951197
EventMsg::AgentReasoning(AgentReasoningEvent { text }) => {
11961198
client.send_agent_thought(text).await;
11971199
}
1198-
EventMsg::Error(ErrorEvent { message })
1199-
| EventMsg::StreamError(StreamErrorEvent { message }) => {
1200-
error!("Error during turn: {}", message);
1200+
EventMsg::StreamError(StreamErrorEvent { message }) => {
1201+
error!("Handled error during turn: {}", message);
1202+
}
1203+
EventMsg::Error(ErrorEvent { message }) => {
1204+
error!("Unhandled error during turn: {}", message);
12011205
if let Some(response_tx) = self.response_tx.take() {
12021206
response_tx
12031207
.send(Err(Error::internal_error().with_data(message)))

0 commit comments

Comments
 (0)