fix: per-node max_tokens + validation 502 guard + correct_jrxml output validity

- backend/llm.py: per-node max_tokens via get_llm(max_tokens=N), LLM_MAX_TOKENS env var (default 8192)
- agent/nodes.py: 5 generation nodes use max_tokens=32768, generate_skeleton retries at 65536
- agent/nodes.py: fix ns:field regex (<field → <[\w:]*field) to handle namespace prefixes
- agent/nodes.py: fix correct_jrxml never writing back to state["current_jrxml"]
- agent/nodes.py: correct_jrxml rejects non-JRXML output (no <jasperReport tag)
- agent/nodes.py: _strip_continuation_wrapper strips markdown/prefixes from continuation rounds
- agent/nodes.py: _extract_jrxml iterates multiple markdown code blocks, skips fragments
- agent/graph.py: route_after_validate skips correction loop when service_unavailable
- agent/graph.py: route_after_save skips validation for empty JRXML
- backend/validation.py: returns service_unavailable: True for ConnectError and HTTP 5xx
- Docs: CLAUDE.md v14 changelog, README.md LLM_MAX_TOKENS, .env.example LLM_MAX_TOKENS
This commit is contained in:
2026-05-24 15:20:25 +08:00
parent e362f530ea
commit 4e14334030
8 changed files with 388 additions and 32 deletions
+12 -2
View File
@@ -4,6 +4,7 @@ import os
import httpx
from dotenv import load_dotenv
from httpx import ConnectError, HTTPStatusError
from backend.logger import get_logger
@@ -31,10 +32,19 @@ def validate_jrxml(jrxml_text: str) -> dict:
},
)
return result
except httpx.ConnectError:
except ConnectError:
error_msg = f"无法连接到验证服务 ({VALIDATION_URL})。是否正在运行?"
_val_log.error("验证服务连接失败", extra={"error": error_msg, "url": VALIDATION_URL})
return {"valid": False, "error": error_msg}
return {"valid": False, "error": error_msg, "service_unavailable": True}
except HTTPStatusError as e:
status_code = e.response.status_code
error_msg = f"验证服务返回错误 ({status_code}): {str(e)}"
_val_log.error("验证请求异常", extra={"error": str(e), "url": VALIDATION_URL, "status_code": status_code})
return {
"valid": False,
"error": error_msg,
"service_unavailable": status_code >= 500,
}
except Exception as e:
error_msg = f"验证请求失败: {str(e)}"
_val_log.error("验证请求异常", extra={"error": str(e), "url": VALIDATION_URL})