diff --git a/sdk/python/tests/app_server_harness.py b/sdk/python/tests/app_server_harness.py index 1a80a39d63..7bc6469727 100644 --- a/sdk/python/tests/app_server_harness.py +++ b/sdk/python/tests/app_server_harness.py @@ -77,19 +77,11 @@ class MockSseResponse: return chunks -@dataclass(frozen=True) -class MockJsonResponse: - """One queued JSON response served by the mock Responses API.""" - - body: Json - - class MockResponsesServer: """Local HTTP server that records `/v1/responses` requests and returns SSE.""" def __init__(self) -> None: self._responses: queue.Queue[MockSseResponse] = queue.Queue() - self._compact_responses: queue.Queue[MockJsonResponse] = queue.Queue() self._requests: list[CapturedResponsesRequest] = [] self._requests_lock = threading.Lock() self._server = _ResponsesHttpServer(("127.0.0.1", 0), _ResponsesHandler, self) @@ -144,21 +136,6 @@ class MockResponsesServer: ) ) - def enqueue_compaction_summary(self, summary: str) -> None: - """Queue a compact endpoint response with one synthetic compaction item.""" - self._compact_responses.put( - MockJsonResponse( - body={ - "output": [ - { - "type": "compaction", - "encrypted_content": summary, - } - ] - } - ) - ) - def requests(self) -> list[CapturedResponsesRequest]: """Return all recorded Responses API requests.""" with self._requests_lock: @@ -203,10 +180,6 @@ class MockResponsesServer: """Return the next queued SSE response or fail the HTTP request.""" return self._responses.get_nowait() - def _next_compact_response(self) -> MockJsonResponse: - """Return the next queued compact JSON response or fail the HTTP request.""" - return self._compact_responses.get_nowait() - class AppServerHarness: """Test fixture that points a pinned runtime app-server at MockResponsesServer.""" @@ -303,22 +276,11 @@ class _ResponsesHandler(BaseHTTPRequestHandler): self.send_error(404, f"unexpected GET {self.path}") def do_POST(self) -> None: - """Serve queued responses for `/v1/responses` and compact requests.""" + """Serve queued SSE responses for `/v1/responses` requests.""" length = int(self.headers.get("content-length", "0")) body = self.rfile.read(length) self.server.mock._record_request(self, body) - if self.path.endswith("/v1/responses/compact") or self.path.endswith( - "/responses/compact" - ): - try: - response = self.server.mock._next_compact_response() - except queue.Empty: - self.send_error(500, "no queued compact response") - return - self._send_json(response.body) - return - if not (self.path.endswith("/v1/responses") or self.path.endswith("/responses")): self.send_error(404, f"unexpected POST {self.path}") return diff --git a/sdk/python/tests/test_mock_app_server_integration.py b/sdk/python/tests/test_mock_app_server_integration.py index 1d50969230..1a241ec92f 100644 --- a/sdk/python/tests/test_mock_app_server_integration.py +++ b/sdk/python/tests/test_mock_app_server_integration.py @@ -581,11 +581,13 @@ def test_approval_modes_preserve_real_app_server_state_without_override( ) -> None: """Resume, fork, and next turn should inherit approval settings unless overridden.""" with AppServerHarness(tmp_path) as harness: + harness.responses.enqueue_assistant_message("source seeded", response_id="turn-mode-0") harness.responses.enqueue_assistant_message("turn override", response_id="turn-mode-1") harness.responses.enqueue_assistant_message("turn inherited", response_id="turn-mode-2") with Codex(config=harness.app_server_config()) as codex: source = codex.thread_start(approval_mode=ApprovalMode.deny_all) + source_result = source.run("seed the source rollout") resumed = codex.thread_resume(source.id) forked = codex.thread_fork(source.id) explicit_fork = codex.thread_fork( @@ -634,6 +636,7 @@ def test_approval_modes_preserve_real_app_server_state_without_override( assert { "policies": inherited_policies, "final_responses": [ + source_result.final_response, first_result.final_response, second_result.final_response, ], @@ -645,7 +648,7 @@ def test_approval_modes_preserve_real_app_server_state_without_override( "after_turn_override": AskForApprovalValue.never.value, "after_omitted_turn": AskForApprovalValue.never.value, }, - "final_responses": ["turn override", "turn inherited"], + "final_responses": ["source seeded", "turn override", "turn inherited"], } @@ -757,7 +760,10 @@ def test_models_and_compact_use_real_app_server_rpcs(tmp_path) -> None: """Model listing and compaction should go through real app-server methods.""" with AppServerHarness(tmp_path) as harness: harness.responses.enqueue_assistant_message("history", response_id="compact-history") - harness.responses.enqueue_compaction_summary("compact summary") + harness.responses.enqueue_assistant_message( + "compact summary", + response_id="compact-summary", + ) with Codex(config=harness.app_server_config()) as codex: models = codex.models(include_hidden=True) @@ -781,7 +787,7 @@ def test_models_and_compact_use_real_app_server_rpcs(tmp_path) -> None: "models_payload_has_data": True, "run_final_response": "history", "compact_response": {}, - "request_kinds": ["responses", "compact"], + "request_kinds": ["responses", "responses"], }