fix: AIPlanner JSON-only repair 프롬프트 및 max_tokens 조정

- JSON-only repair 프롬프트의 내용을 간소화하여 명확한 요구사항을 전달하도록 수정
- 재시도 시 max_tokens를 250으로 줄이고, temperature를 0.0으로 설정하여 JSON 포맷 준수율을 높임
- README.md에 변경 사항 반영
This commit is contained in:
kswdev0
2026-03-26 12:56:56 +09:00
parent 9634362002
commit 64cd08297b
2 changed files with 7 additions and 14 deletions

View File

@@ -226,17 +226,10 @@ class AIPlanner:
or "actions 스키마" in str(e)
):
repair_suffix = (
"\n\n[중요] 이전 응답은 JSON 요구사항을 위반했습니다.\n"
"지금은 아래 스키마의 JSON 객체만 '그대로' 반환하세요.\n"
"마크다운/설명 금지.\n"
"응답의 첫 비공백 문자는 반드시 `{` 입니다.\n"
"키 이름과 구문은 동일해야 합니다.\n"
"{"
"\"thinking\":\"\","
"\"current_goal\":\"\","
"\"actions\":[{\"action\":\"explore\",\"params\":{},\"reason\":\"\"}],"
"\"after_this\":\"\""
"}"
"\n\n[중요] JSON-only. 분석/설명/마크다운 금지.\n"
"응답은 반드시 첫 비공백 문자가 `{` 이고, 마지막도 `}` 입니다.\n"
"아래 JSON 스키마를 그대로(키/구조 동일) 반환하세요:\n"
"{\"thinking\":\"\",\"current_goal\":\"\",\"actions\":[{\"action\":\"wait\",\"params\":{\"seconds\":1},\"reason\":\"repair\"}],\"after_this\":\"재시도\"}"
)
if _glm_debug_enabled():
print("[GLM][디버그] JSON-only repair 프롬프트 적용")
@@ -359,7 +352,7 @@ class AIPlanner:
base_max_tokens = int(os.environ.get("GLM_MAX_TOKENS", "2000"))
retry_max_tokens = int(os.environ.get("GLM_RETRY_MAX_TOKENS", "900"))
repair_max_tokens = int(os.environ.get("GLM_REPAIR_MAX_TOKENS", "600"))
repair_max_tokens = int(os.environ.get("GLM_REPAIR_MAX_TOKENS", "250"))
if repair_mode:
max_tokens = repair_max_tokens
@@ -369,7 +362,7 @@ class AIPlanner:
temperature = 0.3
if repair_mode:
# JSON 포맷 준수율을 높이기 위해 변동성을 낮춘다.
temperature = float(os.environ.get("GLM_REPAIR_TEMPERATURE", "0.1"))
temperature = float(os.environ.get("GLM_REPAIR_TEMPERATURE", "0.0"))
payload = json.dumps({
"model": GLM_MODEL,