fix: harden structured agent intake
This commit is contained in:
@@ -27,7 +27,7 @@ INTERNAL_MCP_TOKEN=
|
||||
METRICS_TOKEN=
|
||||
AI_RUN_RETENTION_DAYS=90
|
||||
AI_SLOW_RUN_THRESHOLD_SECONDS=20
|
||||
AI_AGENT_MODEL_TIMEOUT_SECONDS=20
|
||||
AI_AGENT_MODEL_TIMEOUT_SECONDS=60
|
||||
KNOWLEDGE_EMBEDDING_DEPLOYMENT_ID=0
|
||||
KNOWLEDGE_EMBEDDING_DIMENSIONS=1536
|
||||
KNOWLEDGE_EMBEDDING_ALLOW_HASH_FALLBACK=false
|
||||
|
||||
@@ -7,6 +7,7 @@ from apps.modelhub.models import ModelDeployment
|
||||
from apps.skills.models import SkillDefinition, SkillVersion
|
||||
|
||||
RELEASE_MARKER = "trusted-ticket-intake-v5-structured-context"
|
||||
TRUSTED_INTAKE_MAX_OUTPUT_TOKENS = 8192
|
||||
CATEGORY_CODES = [
|
||||
"business_issue",
|
||||
"operation_issue",
|
||||
@@ -458,6 +459,7 @@ class Command(BaseCommand):
|
||||
"knowledge_context": [],
|
||||
},
|
||||
temperature_override=0.1,
|
||||
max_output_tokens_override=TRUSTED_INTAKE_MAX_OUTPUT_TOKENS,
|
||||
published_at=timezone.now(),
|
||||
)
|
||||
AgentStepBinding.objects.bulk_create(
|
||||
|
||||
@@ -408,20 +408,30 @@ def _normalize_nested_output(output: Any, output_schema: dict) -> Any:
|
||||
nested_fields = output.get("fields")
|
||||
if isinstance(nested_fields, dict):
|
||||
fields = _complete_object_shape(nested_fields, field_schema)
|
||||
normalized = dict(output)
|
||||
elif field_codes.intersection(output):
|
||||
fields = _complete_object_shape(
|
||||
{code: output[code] for code in field_codes if code in output},
|
||||
field_schema,
|
||||
)
|
||||
normalized = {
|
||||
code: value
|
||||
for code, value in output.items()
|
||||
if code not in field_codes
|
||||
}
|
||||
else:
|
||||
fields = None
|
||||
if fields is not None:
|
||||
questions = output.get("questions", output.get("follow_up_questions", []))
|
||||
return {
|
||||
normalized.pop("follow_up_questions", None)
|
||||
normalized.update(
|
||||
{
|
||||
"fields": fields,
|
||||
"missing_fields": list(output.get("missing_fields", [])),
|
||||
"questions": list(questions) if isinstance(questions, list) else [],
|
||||
}
|
||||
)
|
||||
return normalized
|
||||
return output
|
||||
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ INTERNAL_MCP_TOKEN = os.getenv("INTERNAL_MCP_TOKEN", "")
|
||||
METRICS_TOKEN = os.getenv("METRICS_TOKEN", "")
|
||||
AI_RUN_RETENTION_DAYS = int(os.getenv("AI_RUN_RETENTION_DAYS", "90"))
|
||||
AI_SLOW_RUN_THRESHOLD_SECONDS = int(os.getenv("AI_SLOW_RUN_THRESHOLD_SECONDS", "20"))
|
||||
AI_AGENT_MODEL_TIMEOUT_SECONDS = int(os.getenv("AI_AGENT_MODEL_TIMEOUT_SECONDS", "20"))
|
||||
AI_AGENT_MODEL_TIMEOUT_SECONDS = int(os.getenv("AI_AGENT_MODEL_TIMEOUT_SECONDS", "60"))
|
||||
KNOWLEDGE_EMBEDDING_DEPLOYMENT_ID = int(
|
||||
os.getenv("KNOWLEDGE_EMBEDDING_DEPLOYMENT_ID", "0")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user