feat: harden seat intent and expand HIL coverage
This commit is contained in:
@@ -6,7 +6,10 @@ import unittest
|
||||
import urllib.error
|
||||
from unittest.mock import patch
|
||||
|
||||
from cognitive_agent.infrastructure.llm.openai_responses import OpenAIIntentInterpreter
|
||||
from cognitive_agent.infrastructure.llm.openai_responses import (
|
||||
SYSTEM_PROMPT,
|
||||
OpenAIIntentInterpreter,
|
||||
)
|
||||
|
||||
|
||||
INTENT = {
|
||||
@@ -45,10 +48,37 @@ class FakeResponse:
|
||||
|
||||
|
||||
class OpenAIResponsesTests(unittest.TestCase):
|
||||
def test_blank_model_and_base_url_use_documented_defaults(self) -> None:
|
||||
with patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
"OPENAI_API_KEY": " test-key ",
|
||||
"OPENAI_MODEL": " ",
|
||||
"OPENAI_BASE_URL": "",
|
||||
"OPENAI_REASONING_EFFORT": " ",
|
||||
},
|
||||
clear=True,
|
||||
):
|
||||
interpreter = OpenAIIntentInterpreter()
|
||||
|
||||
self.assertEqual(interpreter.api_key, "test-key")
|
||||
self.assertEqual(interpreter.model, "gpt-5.6-sol")
|
||||
self.assertEqual(interpreter.responses_endpoint, "https://api.openai.com/v1/responses")
|
||||
self.assertEqual(interpreter.reasoning_effort, "medium")
|
||||
|
||||
def test_fuzzy_front_cabin_goal_has_deterministic_ergonomic_policy(self) -> None:
|
||||
normalized = " ".join(SYSTEM_PROMPT.split())
|
||||
self.assertIn("front cabin is cramped", normalized)
|
||||
self.assertIn("longitudinal 80%", normalized)
|
||||
self.assertIn("backrest recline 35%", normalized)
|
||||
self.assertIn("do not manufacture a driver-seat target", normalized)
|
||||
|
||||
def test_non_streaming_structured_output(self) -> None:
|
||||
response_body = json.dumps({"output_text": json.dumps(INTENT)})
|
||||
environment = {
|
||||
"OPENAI_API_KEY": "test-key",
|
||||
"OPENAI_MODEL": "gpt-5.6-sol",
|
||||
"OPENAI_BASE_URL": "https://api.openai.com/v1",
|
||||
"OPENAI_STREAM": "false",
|
||||
}
|
||||
|
||||
@@ -73,6 +103,11 @@ class OpenAIResponsesTests(unittest.TestCase):
|
||||
request_payload = json.loads(urlopen.call_args.args[0].data.decode("utf-8"))
|
||||
self.assertEqual(result, INTENT)
|
||||
self.assertNotIn("stream", request_payload)
|
||||
self.assertEqual(request_payload["model"], "gpt-5.6-sol")
|
||||
self.assertEqual(
|
||||
urlopen.call_args.args[0].full_url,
|
||||
"https://api.openai.com/v1/responses",
|
||||
)
|
||||
self.assertIn("capability registry", request_payload["input"][1]["content"][0]["text"])
|
||||
self.assertIn('"level": 1', request_payload["input"][2]["content"][0]["text"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user