"terminated" isn't in the codebase as a literal string being set as an error message. Let me look at the session file again more closely - the error message was "terminated" which suggests it might be coming from outside the pi codebase, possibly from the API itself or the stream ending.
Looking back at the provider code:
- The
parseSSE generator just yields events and exits when done is true
processStream processes those events but doesn't throw if the stream ends early
- The main catch block sets
errorMessage from whatever error was thrown
The "terminated" error could be:
- Coming from the Codex API as an error event
- A network error message
- Something in the fetch/stream handling
Looking at the error handling in processStream:
If the API sent an error event with message "terminated", it would be thrown as "Codex error: terminated". But the log shows just "terminated".
Wait - maybe the error event had message: "terminated" and code: "", and the template literal resulted in just the message. But no, it would still have "Codex error: " prefix.
Let me check if there's handling for incomplete streams or if the stream can emit "terminated" as a raw status. Maybe I should search for how the stream ending is detected or if there's special handling when usage is 0.
Actually, looking at the session data again:
usage: {input: 0, output: 0, ...} - zero tokens
- The thinking content was truncated
This suggests the stream was interrupted before any response.completed or response.done event was received (which is where usage would be populated). The stream ended without completing normally.
I need to trace through the stream handling to see if there's a code path where "terminated" gets thrown directly, or if it's being caught and re-thrown somewhere without the "Codex error: " prefix. The zero usage and truncated thinking point to an early stream termination.