diff --git a/e2e/proxy_test.py b/e2e/proxy_test.py index 6e087615c..fb33f09fb 100644 --- a/e2e/proxy_test.py +++ b/e2e/proxy_test.py @@ -238,33 +238,6 @@ class ProxyTests(unittest.TestCase): self.post({"model": "missing/x", "messages": OPENING}) self.assertEqual(rejected.exception.code, 400) - def test_sdk_history_and_provider_extras(self): - with self.post( - { - "model": self.chat, - "messages": OPENING - + [ - { - "role": "assistant", - "content": None, - "refusal": None, - "reasoning_content": "checking", - "tool_calls": [CALL], - }, - {"role": "tool", "tool_call_id": "call-1", "content": "a.txt"}, - ], - "stream": True, - "tools": TOOLS, - "include_reasoning": True, - "enable_thinking": True, - "chat_template_kwargs": {"enable_thinking": True}, - "provider": {"order": ["z-ai"]}, - "prompt_cache_key": "conversation", - "reasoning": {"enabled": True}, - } - ) as response: - self.assertIn(b"ran it", response.read()) - def test_ingress_limits_and_origin_refuse_before_provider_work(self): path = "/extensions/proxy/v1/chat/completions" for framing, expected_status, code in ( @@ -382,27 +355,6 @@ class ProxyTests(unittest.TestCase): "unknown model", json.load(rejected.exception)["error"]["message"] ) - def test_an_effort_the_model_does_not_take_is_refused_before_the_provider(self): - for model, effort, accepted in ( - (self.think, "medium", "available: none, low, high"), - (self.chat, "low", "takes no reasoning effort"), - ): - with ( - self.subTest(model=model), - self.assertRaises(urllib.error.HTTPError) as rejected, - ): - self.post( - {"model": model, "messages": OPENING, "reasoning_effort": effort} - ) - self.assertEqual(rejected.exception.code, 400) - self.assertIn(accepted, json.load(rejected.exception)["error"]["message"]) - self.assertFalse(self.provider.requests) - with self.post( - {"model": self.think, "messages": OPENING, "reasoning_effort": "none"} - ): - pass - self.assertEqual(self.sent()[1]["reasoning_effort"], "none") - def test_streamed_chat_deltas_usage_and_provider_routing(self): with self.post( { @@ -448,40 +400,6 @@ class ProxyTests(unittest.TestCase): self.assertEqual(sent["model"], "m-chat") self.assertEqual(sent["messages"][0], OPENING[0]) - def test_chat_and_responses_history_projection(self): - for model in (f"{self.chat}/m-chat", f"{self.resp}/m-resp"): - with self.subTest(model=model): - with self.post( - {"model": model, "messages": HISTORY, "tools": TOOLS} - ) as response: - completion = json.load(response) - self.assertEqual(completion["object"], "chat.completion") - self.assertEqual(completion["choices"][0]["finish_reason"], "stop") - path, sent = self.sent() - if model.startswith(self.chat): - self.assertEqual( - [message["role"] for message in sent["messages"]], - ["system", "user", "assistant", "tool"], - ) - self.assertEqual( - sent["messages"][2]["tool_calls"][0]["id"], "call-1" - ) - else: - self.assertTrue(path.endswith("/v1/responses"), path) - self.assertEqual(sent["instructions"], "be brief") - self.assertEqual( - [item.get("type", item.get("role")) for item in sent["input"]], - ["user", "assistant", "function_call", "function_call_output"], - ) - self.assertEqual( - sent["input"][3], - { - "type": "function_call_output", - "call_id": "call-1", - "output": "a.txt", - }, - ) - def test_response_state_round_trips_only_to_originating_profile(self): ask = [{"role": "user", "content": "call a tool"}] with self.post( diff --git a/extensions/proxy/test/albedo_ext_proxy/chat_test.gleam b/extensions/proxy/test/albedo_ext_proxy/chat_test.gleam index 7775fba5e..0674d8127 100644 --- a/extensions/proxy/test/albedo_ext_proxy/chat_test.gleam +++ b/extensions/proxy/test/albedo_ext_proxy/chat_test.gleam @@ -208,3 +208,20 @@ pub fn a_named_effort_is_read_as_one_or_refused_test() -> Nil { == Ok(Some(types.NoReasoning)) assert effort("\"reasoning_effort\":\"turbo\"") == Error(Nil) } + +/// SDKs send history and provider extras the proxy does not use: a refusal +/// and reasoning text on an assistant turn, provider routing, cache keys and +/// thinking switches. Reading the request must not refuse them, and the tool +/// turn still pairs with its result. +pub fn sdk_extras_are_accepted_and_history_still_pairs_test() -> Nil { + let assert Ok(completion) = + parse( + "{\"model\":\"p/m\",\"messages\":[{\"role\":\"system\",\"content\":\"be brief\"},{\"role\":\"user\",\"content\":\"list files\"},{\"role\":\"assistant\",\"content\":null,\"refusal\":null,\"reasoning_content\":\"checking\",\"tool_calls\":[{\"id\":\"call-1\",\"type\":\"function\",\"function\":{\"name\":\"bash\",\"arguments\":\"{}\"}}]},{\"role\":\"tool\",\"tool_call_id\":\"call-1\",\"content\":\"a.txt\"}],\"stream\":true,\"include_reasoning\":true,\"enable_thinking\":true,\"chat_template_kwargs\":{\"enable_thinking\":true},\"provider\":{\"order\":[\"z-ai\"]},\"prompt_cache_key\":\"conversation\",\"reasoning\":{\"enabled\":true}}", + ) + let assert [ + types.User("list files"), + types.Replay(_), + types.ToolOutput("call-1", "a.txt", []), + ] = inputs(completion) + assert completion.request.instructions == Some("be brief") +}