codex-sdk-python 0.105.0__tar.gz → 0.114.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/PKG-INFO +70 -135
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/README.md +67 -132
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/pyproject.toml +7 -4
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/__init__.py +11 -5
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/app_server.py +267 -209
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/integrations/pydantic_ai_model.py +119 -23
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/abort.py +0 -0
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/codex.py +0 -0
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/config_overrides.py +0 -0
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/events.py +0 -0
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/exceptions.py +0 -0
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/exec.py +0 -0
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/hooks.py +0 -0
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/integrations/__init__.py +0 -0
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/integrations/pydantic_ai.py +0 -0
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/items.py +0 -0
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/options.py +0 -0
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/telemetry.py +0 -0
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/thread.py +0 -0
- {codex_sdk_python-0.105.0 → codex_sdk_python-0.114.0}/src/codex_sdk/tool_envelope.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: codex-sdk-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.114.0
|
|
4
4
|
Summary: Python SDK for the Codex CLI agent with async threads, streaming events, and structured outputs
|
|
5
5
|
Keywords: codex,sdk,python,api,cli,agent,async,streaming
|
|
6
6
|
Author: Vectorfy Co
|
|
@@ -18,9 +18,9 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
19
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
20
|
Classifier: Topic :: Software Development :: Build Tools
|
|
21
|
-
Requires-Dist: logfire ; extra == 'logfire'
|
|
21
|
+
Requires-Dist: logfire-api>=4 ; extra == 'logfire'
|
|
22
22
|
Requires-Dist: pydantic>=2 ; extra == 'pydantic'
|
|
23
|
-
Requires-Dist: pydantic-ai ; python_full_version >= '3.10' and extra == 'pydantic-ai'
|
|
23
|
+
Requires-Dist: pydantic-ai>=1.68.0,<2 ; python_full_version >= '3.10' and extra == 'pydantic-ai'
|
|
24
24
|
Maintainer: Vectorfy Co
|
|
25
25
|
Maintainer-email: Vectorfy Co <git@vectorfy.co>
|
|
26
26
|
Requires-Python: >=3.8
|
|
@@ -44,7 +44,7 @@ Embed the Codex agent in Python workflows. This SDK wraps the bundled `codex` CL
|
|
|
44
44
|
<td><strong>Lifecycle</strong></td>
|
|
45
45
|
<td>
|
|
46
46
|
<a href="#ci-cd"><img src="https://img.shields.io/badge/CI%2FCD-Active-16a34a?style=flat&logo=githubactions&logoColor=white" alt="CI/CD badge" /></a>
|
|
47
|
-
<img src="https://img.shields.io/badge/Release-0.
|
|
47
|
+
<img src="https://img.shields.io/badge/Release-0.114.0-6b7280?style=flat&logo=pypi&logoColor=white" alt="Release badge" />
|
|
48
48
|
<a href="#license"><img src="https://img.shields.io/badge/License-Apache--2.0-0f766e?style=flat&logo=apache&logoColor=white" alt="License badge" /></a>
|
|
49
49
|
</td>
|
|
50
50
|
</tr>
|
|
@@ -73,7 +73,7 @@ Embed the Codex agent in Python workflows. This SDK wraps the bundled `codex` CL
|
|
|
73
73
|
</div>
|
|
74
74
|
|
|
75
75
|
- Runtime dependency-free: uses only the Python standard library.
|
|
76
|
-
- Codex CLI binaries
|
|
76
|
+
- Codex CLI binaries are downloaded separately; use `scripts/setup_binary.py` from the repo or install the Codex CLI and set `codex_path_override`.
|
|
77
77
|
- Async-first API with sync helpers, streaming events, and structured output.
|
|
78
78
|
- Python 3.8/3.9 support is deprecated and will be removed in a future release; use Python 3.10+.
|
|
79
79
|
|
|
@@ -168,8 +168,6 @@ python examples/app_server_turn_session.py
|
|
|
168
168
|
python examples/config_overrides.py
|
|
169
169
|
python examples/hooks_streaming.py
|
|
170
170
|
python examples/notify_hook.py
|
|
171
|
-
python examples/pydantic_ai_run_compat.py
|
|
172
|
-
python examples/pydantic_ai_run_stream_compat.py
|
|
173
171
|
```
|
|
174
172
|
|
|
175
173
|
<a id="features"></a>
|
|
@@ -187,15 +185,6 @@ python examples/pydantic_ai_run_stream_compat.py
|
|
|
187
185
|
|  | Cancel running turns via `AbortController` and `AbortSignal`. |
|
|
188
186
|
|  | Optional spans if Logfire is installed and initialized. |
|
|
189
187
|
|
|
190
|
-
### Execution surfaces and transports
|
|
191
|
-
|
|
192
|
-
| Surface | Primary transport | Typical use |
|
|
193
|
-
| ------- | ----------------- | ----------- |
|
|
194
|
-
| `Codex` + `Thread` | `codex exec --experimental-json` (JSONL over stdio) | Conversational turns, streaming item events, structured output (`run_json` / `run_pydantic`). |
|
|
195
|
-
| `AppServerClient` | `codex app-server` (JSON-RPC over stdio) | Full app-server protocol: thread management, turn sessions, approvals, account/config/skills APIs. |
|
|
196
|
-
| `CodexModel` (PydanticAI provider) | `codex app-server` (JSON-RPC over stdio) | Tool-call planning + text generation through app-server turn sessions with incremental stream events. |
|
|
197
|
-
| `codex_handoff_tool` (PydanticAI tool) | `Thread.run(...)` on top of `codex exec` | Delegate repository-aware tasks from another model to Codex. |
|
|
198
|
-
|
|
199
188
|
<a id="configuration"></a>
|
|
200
189
|
## 
|
|
201
190
|
|
|
@@ -323,10 +312,6 @@ For richer integrations (thread fork, requirements, explicit skill input), use t
|
|
|
323
312
|
protocol. The client handles the initialize/initialized handshake and gives you access to
|
|
324
313
|
JSON-RPC notifications.
|
|
325
314
|
|
|
326
|
-
`AppServerClient` starts `codex app-server` and multiplexes notifications + server-initiated
|
|
327
|
-
requests (for example approval requests in `turn_session(...)`) on top of the same stdio
|
|
328
|
-
connection.
|
|
329
|
-
|
|
330
315
|
```python
|
|
331
316
|
import asyncio
|
|
332
317
|
from codex_sdk import AppServerClient, AppServerOptions
|
|
@@ -362,15 +347,20 @@ default prompt) for richer UI integrations.
|
|
|
362
347
|
The SDK also exposes helpers for most app-server endpoints:
|
|
363
348
|
|
|
364
349
|
- Threads: `thread_start`, `thread_resume`, `thread_fork`, `thread_list`, `thread_loaded_list`,
|
|
365
|
-
`thread_read`, `thread_archive`, `
|
|
366
|
-
`thread_compact_start`, `thread_rollback`
|
|
350
|
+
`thread_read`, `thread_archive`, `thread_unsubscribe`, `thread_unarchive`,
|
|
351
|
+
`thread_name_set`, `thread_compact_start`, `thread_rollback`, `thread_metadata_update`
|
|
367
352
|
- Config: `config_read`, `config_value_write`, `config_batch_write`, `config_requirements_read`
|
|
368
|
-
- Skills: `skills_list`, `
|
|
369
|
-
|
|
370
|
-
-
|
|
353
|
+
- Skills: `skills_list`, `skills_remote_list`, `skills_remote_export`, `skills_remote_read` (alias),
|
|
354
|
+
`skills_remote_write` (alias), `skills_config_write`
|
|
355
|
+
- Turns/review: `turn_start`, `turn_steer`, `turn_interrupt`, `review_start`, `turn_session`
|
|
356
|
+
- Models: `model_list`, `experimental_feature_list`
|
|
371
357
|
- Collaboration modes: `collaboration_mode_list` (experimental)
|
|
372
|
-
-
|
|
358
|
+
- Plugins: `plugin_list`, `plugin_install`, `plugin_uninstall`
|
|
359
|
+
- One-off commands: `command_exec`, `command_exec_write`, `command_exec_resize`,
|
|
360
|
+
`command_exec_terminate`
|
|
373
361
|
- MCP auth/status: `mcp_server_oauth_login`, `mcp_server_refresh`, `mcp_server_status_list`
|
|
362
|
+
- External agent config: `external_agent_config_detect`, `external_agent_config_import`
|
|
363
|
+
- Windows sandbox: `windows_sandbox_setup_start`
|
|
374
364
|
- Account: `account_login_start`, `account_login_cancel`, `account_logout`,
|
|
375
365
|
`account_rate_limits_read`, `account_read`
|
|
376
366
|
- Feedback: `feedback_upload`
|
|
@@ -381,21 +371,11 @@ for payload shapes and event semantics.
|
|
|
381
371
|
Note: some endpoints and fields are gated behind an experimental capability; set
|
|
382
372
|
`AppServerOptions(experimental_api_enabled=True)` to opt in.
|
|
383
373
|
|
|
384
|
-
`
|
|
385
|
-
|
|
386
|
-
working directory.
|
|
374
|
+
`ApprovalDecisions` also supports `permissions_request` for auto-responding to
|
|
375
|
+
`item/permissions/requestApproval` server requests during `turn_session()`.
|
|
387
376
|
|
|
388
|
-
`
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
```python
|
|
392
|
-
threads = await app.thread_list(archived=False, sort_key="updatedAt", source_kinds=["local"], cwd=".")
|
|
393
|
-
config = await app.config_read(include_layers=True, cwd=".")
|
|
394
|
-
skills = await app.skills_remote_read(
|
|
395
|
-
cwds=["."], enabled=True, hazelnut_scope="user", product_surface="codex_desktop"
|
|
396
|
-
)
|
|
397
|
-
models = await app.model_list(limit=20, include_hidden=False)
|
|
398
|
-
```
|
|
377
|
+
`thread_list` supports `archived`, `sort_key`, and `source_kinds` filters, and `config_read` accepts an optional `cwd`
|
|
378
|
+
to compute the effective layered config for a specific working directory.
|
|
399
379
|
|
|
400
380
|
### Observability (OTEL) and notify
|
|
401
381
|
|
|
@@ -438,14 +418,8 @@ Supported target triples:
|
|
|
438
418
|
- macOS: `x86_64-apple-darwin`, `aarch64-apple-darwin`
|
|
439
419
|
- Windows: `x86_64-pc-windows-msvc`, `aarch64-pc-windows-msvc`
|
|
440
420
|
|
|
441
|
-
If you are working from source and the vendor directory is missing, run
|
|
442
|
-
`
|
|
443
|
-
artifacts into `src/codex_sdk/vendor/`.
|
|
444
|
-
|
|
445
|
-
`scripts/setup_binary.py` behavior:
|
|
446
|
-
- Resolves `CODEX_NPM_VERSION` when set; otherwise resolves latest `@openai/codex`.
|
|
447
|
-
- Tries legacy `@openai/codex-sdk` package first, then falls back to per-target `@openai/codex@<version>-<suffix>` artifacts.
|
|
448
|
-
- Rebuilds `src/codex_sdk/vendor/` for all supported targets and validates current-platform binary presence.
|
|
421
|
+
If you are working from source and the vendor directory is missing, run `python scripts/setup_binary.py`
|
|
422
|
+
or follow `SETUP.md` to download the official npm package and copy the `vendor/` directory.
|
|
449
423
|
|
|
450
424
|
<a id="auth"></a>
|
|
451
425
|
## 
|
|
@@ -538,6 +512,7 @@ print(turn.final_response)
|
|
|
538
512
|
- `command_execution`
|
|
539
513
|
- `file_change`
|
|
540
514
|
- `mcp_tool_call`
|
|
515
|
+
- `collab_tool_call`
|
|
541
516
|
- `web_search`
|
|
542
517
|
- `todo_list`
|
|
543
518
|
- `error`
|
|
@@ -614,7 +589,8 @@ last_thread = codex.resume_last_thread()
|
|
|
614
589
|
### Turn helpers
|
|
615
590
|
|
|
616
591
|
Each `Turn` provides convenience filters: `agent_messages()`, `reasoning()`, `commands()`,
|
|
617
|
-
`file_changes()`, `mcp_tool_calls()`, `
|
|
592
|
+
`file_changes()`, `mcp_tool_calls()`, `collab_tool_calls()`, `web_searches()`,
|
|
593
|
+
`todo_lists()`, and `errors()`.
|
|
618
594
|
|
|
619
595
|
<a id="api"></a>
|
|
620
596
|
## 
|
|
@@ -635,7 +611,12 @@ Exceptions:
|
|
|
635
611
|
Typed events and items:
|
|
636
612
|
- `ThreadEvent` union of `thread.*`, `turn.*`, `item.*`, and `error` events.
|
|
637
613
|
- `ThreadItem` union of `agent_message`, `reasoning`, `command_execution`, `file_change`,
|
|
638
|
-
`mcp_tool_call`, `web_search`, `todo_list`, `error`.
|
|
614
|
+
`mcp_tool_call`, `collab_tool_call`, `web_search`, `todo_list`, `error`.
|
|
615
|
+
- `CollabToolCallItem`: typed item for `collab_tool_call` thread history entries.
|
|
616
|
+
- `CollabToolCallStatus`: typed status values for collaboration tool calls.
|
|
617
|
+
- `CollabTool`: collaboration tool metadata attached to `CollabToolCallItem`.
|
|
618
|
+
- `CollabAgentStatus`: agent lifecycle status attached to collaboration state updates.
|
|
619
|
+
- `CollabAgentState`: agent metadata/state payload emitted for collaboration items.
|
|
639
620
|
|
|
640
621
|
<a id="examples"></a>
|
|
641
622
|
## 
|
|
@@ -652,9 +633,8 @@ Example scripts under `examples/`:
|
|
|
652
633
|
- `hooks_streaming.py`: event hooks for streaming runs.
|
|
653
634
|
- `notify_hook.py`: notify script for CLI callbacks.
|
|
654
635
|
- `pydantic_ai_model_provider.py`: Codex as a PydanticAI model provider.
|
|
636
|
+
- `pydantic_ai_model_provider_streaming.py`: live PydanticAI text streaming over `CodexModel`.
|
|
655
637
|
- `pydantic_ai_handoff.py`: Codex as a PydanticAI tool.
|
|
656
|
-
- `pydantic_ai_run_compat.py`: minimal compatibility harness for `Agent.run(...)`.
|
|
657
|
-
- `pydantic_ai_run_stream_compat.py`: minimal compatibility harness for `Agent.run_stream(...)`.
|
|
658
638
|
|
|
659
639
|
<a id="sandbox"></a>
|
|
660
640
|
## 
|
|
@@ -677,9 +657,6 @@ Additional controls:
|
|
|
677
657
|
|
|
678
658
|
This SDK offers two ways to integrate with PydanticAI:
|
|
679
659
|
|
|
680
|
-
Note: starting in `0.105.0`, `CodexModel` is app-server-only and no longer supports
|
|
681
|
-
the legacy `CodexModel(codex=...)` fallback path.
|
|
682
|
-
|
|
683
660
|
### 1) Codex as a PydanticAI model provider
|
|
684
661
|
|
|
685
662
|
Use `CodexModel` to delegate tool-call planning and text generation to Codex, while PydanticAI executes tools and validates outputs.
|
|
@@ -706,21 +683,30 @@ result = agent.run_sync("What's 19 + 23? Use the add tool.")
|
|
|
706
683
|
print(result.output)
|
|
707
684
|
```
|
|
708
685
|
|
|
686
|
+
For live text streaming in a terminal or web UI:
|
|
687
|
+
|
|
688
|
+
```python
|
|
689
|
+
from pydantic_ai import Agent
|
|
690
|
+
|
|
691
|
+
from codex_sdk.integrations.pydantic_ai_model import CodexModel
|
|
692
|
+
|
|
693
|
+
agent = Agent(CodexModel(), output_type=str)
|
|
694
|
+
|
|
695
|
+
async with agent.run_stream("Explain why the sky is blue.") as result:
|
|
696
|
+
async for delta in result.stream_text(delta=True, debounce_by=None):
|
|
697
|
+
print(delta, end="", flush=True)
|
|
698
|
+
```
|
|
699
|
+
|
|
709
700
|
How it works:
|
|
710
|
-
- `CodexModel` keeps a persistent app-server session and starts/reuses threads based on
|
|
711
|
-
`thread_reuse_mode` (`"run"` by default, `"always"` optional).
|
|
712
701
|
- `CodexModel` builds a JSON schema envelope with `tool_calls` and `final`.
|
|
713
702
|
- Codex emits tool calls as JSON strings; PydanticAI runs them.
|
|
714
703
|
- If `allow_text_output` is true, Codex can place final text in `final`.
|
|
715
|
-
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
-
|
|
719
|
-
- `
|
|
720
|
-
|
|
721
|
-
Lifecycle:
|
|
722
|
-
- `CodexModel` owns an app-server client by default; call `await model.close()` in
|
|
723
|
-
long-lived processes to release resources.
|
|
704
|
+
- This SDK targets the current PydanticAI release line (`>=1.68.0,<2`).
|
|
705
|
+
- `Agent.run_stream()`, `Agent.run_stream_events()`, and `Agent.run_stream_sync()`
|
|
706
|
+
work with `CodexModel`.
|
|
707
|
+
- Text deltas are forwarded live from agent-message updates when Codex emits them, including
|
|
708
|
+
envelope-backed `final` text. Tool calls are forwarded as soon as Codex produces a valid
|
|
709
|
+
envelope update, and `streamed.get()` is reconciled to the canonical final turn result.
|
|
724
710
|
|
|
725
711
|
Safety defaults (you can override with your own `ThreadOptions`):
|
|
726
712
|
- `sandbox_mode="read-only"`
|
|
@@ -783,49 +769,38 @@ If `logfire` is installed and initialized, the SDK emits spans:
|
|
|
783
769
|
If Logfire is missing or not initialized, the span context manager is a no-op.
|
|
784
770
|
|
|
785
771
|
<a id="architecture"></a>
|
|
772
|
+
<a id="acheature"></a>
|
|
786
773
|
## 
|
|
787
774
|
|
|
788
|
-
### System components
|
|
775
|
+
### System components
|
|
789
776
|
|
|
790
777
|
```mermaid
|
|
791
778
|
flowchart LR
|
|
792
779
|
subgraph App[Your Python App]
|
|
793
780
|
U[User Code]
|
|
794
|
-
T[
|
|
795
|
-
A[AppServerClient API]
|
|
796
|
-
PM[PydanticAI CodexModel]
|
|
797
|
-
PH[PydanticAI codex_handoff_tool]
|
|
781
|
+
T[Thread API]
|
|
798
782
|
end
|
|
799
783
|
|
|
800
784
|
subgraph SDK[Codex SDK]
|
|
801
785
|
C[Codex]
|
|
802
786
|
E[CodexExec]
|
|
803
|
-
P[
|
|
804
|
-
R[JSON-RPC Client]
|
|
787
|
+
P[Event Parser]
|
|
805
788
|
end
|
|
806
789
|
|
|
807
|
-
subgraph CLI[Codex CLI]
|
|
790
|
+
subgraph CLI[Bundled Codex CLI]
|
|
808
791
|
X["codex exec --experimental-json"]
|
|
809
|
-
S["codex app-server"]
|
|
810
792
|
end
|
|
811
793
|
|
|
812
794
|
FS[(Filesystem)]
|
|
813
795
|
NET[(Network)]
|
|
814
796
|
|
|
815
797
|
U --> T --> C --> E --> X
|
|
816
|
-
U --> A --> R --> S
|
|
817
|
-
U --> PM --> R
|
|
818
|
-
U --> PH --> C
|
|
819
798
|
X -->|JSONL events| P --> T
|
|
820
|
-
S -->|JSON-RPC messages| R --> A
|
|
821
|
-
S -->|JSON-RPC messages| R --> PM
|
|
822
799
|
X --> FS
|
|
823
800
|
X --> NET
|
|
824
|
-
S --> FS
|
|
825
|
-
S --> NET
|
|
826
801
|
```
|
|
827
802
|
|
|
828
|
-
###
|
|
803
|
+
### Streaming event lifecycle
|
|
829
804
|
|
|
830
805
|
```mermaid
|
|
831
806
|
sequenceDiagram
|
|
@@ -848,41 +823,21 @@ sequenceDiagram
|
|
|
848
823
|
Thread-->>Dev: turn.completed / turn.failed
|
|
849
824
|
```
|
|
850
825
|
|
|
851
|
-
###
|
|
852
|
-
|
|
853
|
-
```mermaid
|
|
854
|
-
sequenceDiagram
|
|
855
|
-
participant Dev as Developer
|
|
856
|
-
participant App as AppServerClient
|
|
857
|
-
participant CLI as codex app-server
|
|
858
|
-
|
|
859
|
-
Dev->>App: start()
|
|
860
|
-
App->>CLI: spawn process
|
|
861
|
-
App->>CLI: initialize
|
|
862
|
-
CLI-->>App: initialize result
|
|
863
|
-
App->>CLI: initialized (notification)
|
|
864
|
-
Dev->>App: turn_session(thread_id, input)
|
|
865
|
-
App->>CLI: turn/start
|
|
866
|
-
CLI-->>App: thread/turn/item notifications
|
|
867
|
-
CLI-->>App: request (approval needed)
|
|
868
|
-
App-->>CLI: response (approve/reject)
|
|
869
|
-
CLI-->>App: turn completed notification
|
|
870
|
-
App-->>Dev: final turn payload
|
|
871
|
-
```
|
|
872
|
-
|
|
873
|
-
### PydanticAI model-provider loop (current implementation)
|
|
826
|
+
### PydanticAI model-provider loop
|
|
874
827
|
|
|
875
828
|
```mermaid
|
|
876
829
|
sequenceDiagram
|
|
877
830
|
participant Agent as PydanticAI Agent
|
|
878
831
|
participant Model as CodexModel
|
|
879
|
-
participant
|
|
832
|
+
participant SDK as Codex SDK
|
|
833
|
+
participant CLI as codex exec
|
|
880
834
|
participant Tools as User Tools
|
|
881
835
|
|
|
882
836
|
Agent->>Model: request(messages, tools)
|
|
883
|
-
Model->>
|
|
884
|
-
|
|
885
|
-
|
|
837
|
+
Model->>SDK: start_thread + run_json(prompt, output_schema)
|
|
838
|
+
SDK->>CLI: codex exec --output-schema
|
|
839
|
+
CLI-->>SDK: JSON envelope {tool_calls, final}
|
|
840
|
+
SDK-->>Model: ParsedTurn
|
|
886
841
|
alt tool_calls present
|
|
887
842
|
Model-->>Agent: ToolCallPart(s)
|
|
888
843
|
Agent->>Tools: execute tool(s)
|
|
@@ -898,18 +853,12 @@ sequenceDiagram
|
|
|
898
853
|
flowchart LR
|
|
899
854
|
Agent[PydanticAI Agent] --> Tool[codex_handoff_tool]
|
|
900
855
|
Tool --> SDK[Codex SDK Thread]
|
|
901
|
-
SDK --> CLI[
|
|
856
|
+
SDK --> CLI[Codex CLI]
|
|
902
857
|
CLI --> SDK
|
|
903
858
|
SDK --> Tool
|
|
904
859
|
Tool --> Agent
|
|
905
860
|
```
|
|
906
861
|
|
|
907
|
-
### Streaming semantics summary
|
|
908
|
-
|
|
909
|
-
- `Thread.run_streamed()` and `Thread.run_streamed_events()` stream incremental `ThreadEvent` values as JSONL lines arrive from `codex exec`.
|
|
910
|
-
- `AppServerClient.notifications()` streams incremental JSON-RPC notifications from `codex app-server`.
|
|
911
|
-
- `CodexModel.request_stream(...)` emits incremental events from app-server turn notifications, with compatibility handling for current and legacy PydanticAI stream interfaces.
|
|
912
|
-
|
|
913
862
|
<a id="testing"></a>
|
|
914
863
|
## 
|
|
915
864
|
|
|
@@ -918,12 +867,9 @@ This repo uses unit tests with mocked CLI processes to keep the test suite fast
|
|
|
918
867
|
Test focus areas:
|
|
919
868
|
- `tests/test_exec.py`: CLI invocation, environment handling, config flags, abort behavior.
|
|
920
869
|
- `tests/test_thread.py`: parsing, streaming, JSON schema, Pydantic validation, input normalization.
|
|
921
|
-
- `tests/test_app_server.py` and `tests/test_app_server_session.py`: JSON-RPC lifecycle, method wrappers, turn-session approvals/notifications.
|
|
922
870
|
- `tests/test_codex.py`: resume helpers and option wiring.
|
|
923
|
-
- `tests/test_config_overrides.py`: `--config` serialization and merge behavior.
|
|
924
871
|
- `tests/test_abort.py`: abort signal semantics.
|
|
925
872
|
- `tests/test_telemetry.py`: Logfire span behavior.
|
|
926
|
-
- `tests/test_tool_envelope.py`: tool envelope parsing and schema normalization helpers.
|
|
927
873
|
- `tests/test_pydantic_ai_*`: PydanticAI model provider and handoff integration.
|
|
928
874
|
|
|
929
875
|
### Run tests
|
|
@@ -965,21 +911,10 @@ uv run mypy src
|
|
|
965
911
|
## 
|
|
966
912
|
|
|
967
913
|
This repository includes GitHub Actions workflows under `.github/workflows/`.
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
- `publish.yml`: builds (`uv build --no-sources`) and publishes to PyPI on release publish (or successful release workflow).
|
|
973
|
-
- `docs-deploy.yml`: optional docs deployment (gated by `DOCS_DEPLOY_ENABLED`).
|
|
974
|
-
- `uv-lock-update.yml`: scheduled weekly lockfile refresh PR.
|
|
975
|
-
|
|
976
|
-
`ci.yml` test jobs install Node.js and run:
|
|
977
|
-
|
|
978
|
-
```bash
|
|
979
|
-
python scripts/setup_binary.py
|
|
980
|
-
```
|
|
981
|
-
|
|
982
|
-
before `pytest`, so test runs do not depend on committed vendor binary updates.
|
|
914
|
+
The CI pipeline runs linting, type checks, and `pytest --cov=codex_sdk`.
|
|
915
|
+
Release automation creates GitHub releases from `CHANGELOG_SDK.md` when you push a
|
|
916
|
+
`vX.Y.Z` tag or manually dispatch the workflow, then the publish workflow uploads
|
|
917
|
+
the package to PyPI on release publish.
|
|
983
918
|
|
|
984
919
|
<a id="operations"></a>
|
|
985
920
|
## 
|