Expose Python SDK history selection and per-turn options (#44084)

## Why

Python callers need control over response history loading and a way to override the service tier for one turn. These options also need runtime compatibility checks to prevent older CLIs from silently ignoring them.

## What changed

- Add `include_turns` to sync and async thread resume/fork methods. Omission preserves server defaults; `False` skips response history loading without changing model context.
- Add `turn_service_tier` and `source` to sync and async `run()` and `turn()`, and generate both methods together to keep their options aligned.
- Require CLI `0.151.0` or newer when sending the new options, with lazy schema checks for unversioned local builds.
- Pin the bundled runtime dependency to `0.153.4` and reject unsupported runtime versions during SDK packaging.

## Testing

Add coverage for option forwarding, history flag omission and inversion, runtime version checks, cached schema probing, and packaging compatibility. Extend app-server and installed SDK smoke tests to exercise the new options.

GitOrigin-RevId: 4bcc9cff687b0651e67852e7c080df7fadac6d76
This commit is contained in:
Ahmed Ibrahim
2026-09-09 06:40:56 +00:00
committed by copyberry
parent 7b9e7d99bd
commit 8afccec87a
14 changed files with 667 additions and 108 deletions
+14
View File
@@ -52,6 +52,20 @@ def test_sync_thread_run_uses_mock_responses(
}
def test_checkout_supports_new_options_and_history_selection(tmp_path) -> None:
with AppServerHarness(tmp_path) as harness:
harness.responses.enqueue_assistant_message("Options supported")
with Codex(config=harness.app_server_config()) as codex:
thread = codex.thread_start()
result = thread.run("hello", turn_service_tier="default", source="automation")
resumed = codex.thread_resume(thread.id, include_turns=False)
forked = codex.thread_fork(thread.id, include_turns=True)
assert result.final_response == "Options supported"
assert resumed.id == thread.id
assert forked.id != thread.id
assert harness.responses.single_request().message_input_texts("user")[-1:] == ["hello"]
def test_run_params_and_usage_cross_app_server_boundary(tmp_path) -> None:
"""Thread.run should pass overrides and collect app-server token usage."""
with AppServerHarness(tmp_path) as harness: