From 8d33f673fd185f073c8eb3d203f1c6b84c1cd215 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Tue, 20 Oct 2026 02:50:08 -0700 Subject: [PATCH] Declare UTF-8 for provider discovery responses Make the response charset explicit so browsers render the snowflake icon correctly. Check the wire header, UTF-8 bytes, decoded document, and byte length together. Verified 11 gateway tests, seven deployment tests, revised schema constraints, and browser reloads against the CPU preview. Assisted-by: gpt-6.1-sol --- service/local-ai/gateway.py | 2 +- service/local-ai/test_gateway.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/service/local-ai/gateway.py b/service/local-ai/gateway.py index 09ed0b3e9864543ccc2aa659cf502a7c121b2b72..cfc23b0d290d0d7f6987aaef63f8e5e535155c3f 100644 --- a/service/local-ai/gateway.py +++ b/service/local-ai/gateway.py @@ -206,7 +206,7 @@ class Handler(BaseHTTPRequestHandler): if self.path.split("?", 1)[0] == "/.well-known/ai-agent-provider.json": content = json.dumps(agent_provider(), ensure_ascii=False).encode() self.send_response(200) - self.send_header("Content-Type", "application/json") + self.send_header("Content-Type", "application/json; charset=utf-8") self.send_header("Cache-Control", "no-store") self.send_header("Content-Length", str(len(content))) self.end_headers() diff --git a/service/local-ai/test_gateway.py b/service/local-ai/test_gateway.py index 0437338c72d28fb8a9c44b83e494bdb06075be77..5eb537018799e9d79b60a9c2c5983b292cd9037c 100644 --- a/service/local-ai/test_gateway.py +++ b/service/local-ai/test_gateway.py @@ -22,10 +22,11 @@ class ResponsesCompatibility(unittest.TestCase): client.request("GET", "/.well-known/ai-agent-provider.json?probe=1", headers=headers) response = client.getresponse() self.assertEqual(response.status, 200) - self.assertEqual(response.getheader("Content-Type"), "application/json") + self.assertEqual(response.getheader("Content-Type"), "application/json; charset=utf-8") content = response.read() self.assertEqual(int(response.getheader("Content-Length")), len(content)) - self.assertEqual(json.loads(content), agent_provider()) + self.assertIn("❄️".encode("utf-8"), content) + self.assertEqual(json.loads(content.decode("utf-8")), agent_provider()) self.assertNotIn(b"disposable-test-key", content) client.request("GET", "/v1/models") response = client.getresponse() -- 2.54.1