mirror of
https://github.com/openai/codex.git
synced 2026-09-10 20:26:47 +00:00
## 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
40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
"""Exercise a built SDK's default runtime in an otherwise isolated environment."""
|
|
|
|
from dataclasses import replace
|
|
from importlib.metadata import distribution, version
|
|
from pathlib import Path
|
|
from tempfile import TemporaryDirectory
|
|
|
|
from app_server_harness import AppServerHarness
|
|
|
|
import openai_codex
|
|
from openai_codex import Codex
|
|
|
|
|
|
def main() -> None:
|
|
installed_root = Path(distribution("openai-codex").locate_file("")).resolve()
|
|
assert Path(openai_codex.__file__).resolve().is_relative_to(installed_root), (
|
|
"The smoke test must import the installed SDK, not the source checkout"
|
|
)
|
|
|
|
with TemporaryDirectory() as directory, AppServerHarness(Path(directory)) as harness:
|
|
harness.responses.enqueue_assistant_message("Installed SDK works")
|
|
config = replace(harness.app_server_config(), codex_bin=None)
|
|
with Codex(config=config) as codex:
|
|
thread = codex.thread_start()
|
|
result = thread.run(
|
|
"Check the installed SDK", turn_service_tier="default", source="automation"
|
|
)
|
|
codex.thread_resume(thread.id, include_turns=False)
|
|
codex.thread_fork(thread.id, include_turns=True)
|
|
assert result.final_response == "Installed SDK works"
|
|
assert harness.responses.single_request().message_input_texts("user")[-1:] == [
|
|
"Check the installed SDK"
|
|
]
|
|
|
|
print(f"Installed SDK passed with CLI runtime {version('openai-codex-cli-bin')}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|