diff --git a/.env.example b/.env.example index ae5f658..00fb446 100644 --- a/.env.example +++ b/.env.example @@ -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 diff --git a/backend/apps/agents/management/commands/publish_trusted_ticket_intake.py b/backend/apps/agents/management/commands/publish_trusted_ticket_intake.py index aceab1b..3b74dfa 100644 --- a/backend/apps/agents/management/commands/publish_trusted_ticket_intake.py +++ b/backend/apps/agents/management/commands/publish_trusted_ticket_intake.py @@ -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( diff --git a/backend/apps/agents/services.py b/backend/apps/agents/services.py index 8291350..79d4be6 100644 --- a/backend/apps/agents/services.py +++ b/backend/apps/agents/services.py @@ -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 { - "fields": fields, - "missing_fields": list(output.get("missing_fields", [])), - "questions": list(questions) if isinstance(questions, list) else [], - } + 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 diff --git a/backend/config/settings/base.py b/backend/config/settings/base.py index a6924af..f69bd7e 100644 --- a/backend/config/settings/base.py +++ b/backend/config/settings/base.py @@ -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") )