From 59df616a7b6b73ee8475180fada7f60f442f1348 Mon Sep 17 00:00:00 2001 From: hbyang Date: Mon, 21 Sep 2026 17:29:29 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20solution/backend:=20=EC=9D=91=EB=8B=B5?= =?UTF-8?q?=20=EC=8A=A4=ED=82=A4=EB=A7=88=20=EB=8C=80=EB=AC=B8=EC=9E=90=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=E2=80=94=20openai=20=EC=97=90=EC=84=9C?= =?UTF-8?q?=EB=A7=8C=20400=20=EC=9C=BC=EB=A1=9C=20=ED=84=B0=EC=A7=80?= =?UTF-8?q?=EB=8D=98=20=EA=B2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OpenAI strict 모드는 'STRING' 을 거부한다: Invalid schema for response_format: 'STRING' is not valid under any of the given schemas Gemini 는 대소문자를 둘 다 받아서, 대문자로 써 두면 **공급자를 openai 로 바꾸는 순간에만** 터진다. LLM_PROVIDER 기본값이 openai 인데 두 파일만 대문자로 남아 있었다 — 대화창은 첫 발화부터 502 였고 SNS 초안도 같은 이유로 못 돌았다. - prompts/agent: 소문자로. args 는 strict 가 전 프로퍼티를 required 로 만드므로 안 쓰는 인자가 빈 문자열로 온다 — 도구는 "" 를 '없음' 으로 읽는다 - prompts/social: 같은 수정. 나머지 프롬프트는 원래 소문자였다 실측 확인: "체크인 시간 3시로 바꿔줘" → set_fact(check_in_time, 15:00) test_agent_runtime·test_social 34 passed Co-Authored-By: Claude Opus 5 (1M context) --- solution/backend/services/prompts/agent.py | 26 ++++++++++++++------- solution/backend/services/prompts/social.py | 9 ++++--- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/solution/backend/services/prompts/agent.py b/solution/backend/services/prompts/agent.py index b96c49c..4d3f0af 100644 --- a/solution/backend/services/prompts/agent.py +++ b/solution/backend/services/prompts/agent.py @@ -11,18 +11,28 @@ import json RESPONSE_SCHEMA = { - "type": "OBJECT", + # ★ 타입 이름은 **소문자**다. OpenAI strict 모드가 대문자('STRING')를 거부한다 — + # `Invalid schema for response_format: 'STRING' is not valid under any of the given schemas`. + # Gemini 는 둘 다 받아서, 대문자로 써 두면 공급자를 openai 로 바꾸는 순간에만 터진다. + "type": "object", "properties": { - # tool: 부를 도구 이름. 못 고르겠으면 빈 문자열. - "tool": {"type": "STRING"}, + # 부를 도구 이름. 못 고르겠으면 빈 문자열. + "tool": {"type": "string"}, + # ★ strict 모드는 모든 프로퍼티를 required 로 만든다(llm/openai._to_strict_schema). + # 그래서 안 쓰는 인자는 빈 문자열로 온다 — 도구는 "" 를 '없음' 으로 읽는다. "args": { - "type": "OBJECT", - "properties": {"key": {"type": "STRING"}, "value": {"type": "STRING"}, "keyword": {"type": "STRING"}}, + "type": "object", + "properties": { + "key": {"type": "string"}, + "value": {"type": "string"}, + "keyword": {"type": "string"}, + }, + "required": ["key", "value", "keyword"], }, - # message: 도구를 못 고른 경우에만 쓴다(되묻기·안내). - "message": {"type": "STRING"}, + # 도구를 못 고른 경우에만 쓴다(되묻기·안내). + "message": {"type": "string"}, }, - "required": ["tool", "message"], + "required": ["tool", "args", "message"], } diff --git a/solution/backend/services/prompts/social.py b/solution/backend/services/prompts/social.py index 3670d45..406ea94 100644 --- a/solution/backend/services/prompts/social.py +++ b/solution/backend/services/prompts/social.py @@ -1,8 +1,11 @@ import json -RESPONSE_SCHEMA = {'type': 'OBJECT', 'properties': { - 'body': {'type': 'STRING'}, - 'fact_keys': {'type': 'ARRAY', 'items': {'type': 'STRING'}}, +# ★ 타입 이름은 소문자다. OpenAI strict 모드가 대문자('STRING')를 거부한다 — +# Gemini 는 둘 다 받아서, 대문자로 두면 **공급자를 openai 로 바꾸는 순간에만** 터진다 +# (실측 2026-09-21: LLM_PROVIDER 기본값이 openai 인데 이 파일만 대문자로 남아 있었다). +RESPONSE_SCHEMA = {'type': 'object', 'properties': { + 'body': {'type': 'string'}, + 'fact_keys': {'type': 'array', 'items': {'type': 'string'}}, }, 'required': ['body', 'fact_keys']}