mirror of
https://github.com/openai/codex.git
synced 2026-10-28 18:58:46 +00:00
## Why Slow consumers can lose process output or block control replies when the in-process event queue fills. Descendants can also keep output streams open after the child exits, leaving clients unable to tell whether captured output is complete. ## What changed - Require delivery of `process/outputDelta` and `process/exited` notifications, while allowing process request replies to proceed when event delivery is blocked. - Exclude time spent delivering output to slow clients from the post-exit drain budget, and drain queued bytes after the deadline closes a stream. - Keep draining after an output byte cap is reached so the child can finish writing; abort each stream's reader when its drain deadline expires. - Add optional `outputDrainTimedOut` to `process/exited` and generated bindings. Report incomplete output separately from the child's exit code, treating a fully captured requested byte cap as complete. - Deliver the exit notification before moving Windows console cleanup to a blocking task. ## Testing Add regression coverage for full event queues, stalled consumers issuing process control requests, slow output delivery, inherited pipes, output caps, Windows console descendants, and compatibility with exit notifications that omit `outputDrainTimedOut`. GitOrigin-RevId: 04cfeea5daa7c2b833cdec3f1fff7efeb4d1a86e
OpenAI Codex Python SDK
Build Python applications that start Codex threads, run turns, stream progress, and control workspace access.
Install
Install the SDK:
pip install openai-codex
Quickstart
The SDK reuses your existing Codex authentication when one is already available:
from openai_codex import Codex
with Codex() as codex:
thread = codex.thread_start()
result = thread.run("Explain this repository in three bullets.")
print(result.final_response)
thread.run(...) returns a TurnResult containing the final response,
collected items, and token usage.
Authentication
Existing Codex authentication is reused automatically. To start ChatGPT browser login explicitly:
from openai_codex import Codex
with Codex() as codex:
login = codex.login_chatgpt()
print(login.auth_url)
print(login.wait().success)
For device-code login:
with Codex() as codex:
login = codex.login_chatgpt_device_code()
print(login.verification_url, login.user_code)
login.wait()
For API-key login:
with Codex() as codex:
codex.login_api_key("sk-...")
Built-In Help
Use Python's standard help(openai_codex), help(Codex), or
python -m pydoc openai_codex documentation tools.
Documentation
The package is licensed under the repository Apache License 2.0.