diff --git a/sdk/python/examples/02_turn_run/async.py b/sdk/python/examples/02_turn_run/async.py index 5d25d367c8..e6fe5f7cbe 100644 --- a/sdk/python/examples/02_turn_run/async.py +++ b/sdk/python/examples/02_turn_run/async.py @@ -19,6 +19,11 @@ async def main() -> None: thread = await codex.thread_start(model="gpt-5.4", config={"model_reasoning_effort": "high"}) turn = await thread.turn(TextInput("Give 3 bullets about SIMD.")) result = await turn.run() + persisted = await thread.read(include_turns=True) + persisted_turn = next( + (turn for turn in persisted.thread.turns or [] if turn.id == result.turn_id), + None, + ) print("thread_id:", result.thread_id) print("turn_id:", result.turn_id) @@ -26,7 +31,10 @@ async def main() -> None: if result.error is not None: print("error:", result.error) print("text:", result.text) - print("items.count:", len(result.items)) + print( + "persisted.items.count:", + 0 if persisted_turn is None else len(persisted_turn.items or []), + ) if result.usage is None: raise RuntimeError("missing usage for completed turn") print("usage.thread_id:", result.usage.thread_id) diff --git a/sdk/python/examples/02_turn_run/sync.py b/sdk/python/examples/02_turn_run/sync.py index 89b1411571..5d53224edf 100644 --- a/sdk/python/examples/02_turn_run/sync.py +++ b/sdk/python/examples/02_turn_run/sync.py @@ -14,6 +14,11 @@ from codex_app_server import Codex, TextInput with Codex(config=runtime_config()) as codex: thread = codex.thread_start(model="gpt-5.4", config={"model_reasoning_effort": "high"}) result = thread.turn(TextInput("Give 3 bullets about SIMD.")).run() + persisted = thread.read(include_turns=True) + persisted_turn = next( + (turn for turn in persisted.thread.turns or [] if turn.id == result.turn_id), + None, + ) print("thread_id:", result.thread_id) print("turn_id:", result.turn_id) @@ -21,7 +26,10 @@ with Codex(config=runtime_config()) as codex: if result.error is not None: print("error:", result.error) print("text:", result.text) - print("items.count:", len(result.items)) + print( + "persisted.items.count:", + 0 if persisted_turn is None else len(persisted_turn.items or []), + ) if result.usage is None: raise RuntimeError("missing usage for completed turn") print("usage.thread_id:", result.usage.thread_id)