The current turn input in the agent loop is being discarded before consuming the stream events which causes the stream reconnect (after rate limit failure) to not include the inputs. Since the new stream includes the previous response ID, it triggers a bad request exception considering the input doesn't match what OpenAI has stored on the server side and subsequently a very confusing error message of: `No tool output found for function call call_xyz`. This should fix https://github.com/openai/codex/issues/586. ## Testing I have a personal project that I'm working on that runs multiple Codex CLIs in parallel and often runs into rate limit errors (as seen in the OpenAI logs). After making this change, I am no longer experiencing Codex crashing and it was able to retry and handle everything gracefully until completion (even though I still see rate limiting in the OpenAI logs).
61 KiB
61 KiB