Files
dify/api/services/dify_builder/json_execution_presentation.py
T
twwu 89504b7dce refactor(builder): localize fixed copy on the frontend
Move fixed copy into the difyBuilder i18n namespace and resolve scene IDs
using reply_language. Preserve dynamic streaming, historical receipts,
and submitted values.

Show fixed replies immediately with a short transition, detect language
before initial progress, and retire new notices and recovery messages.
Keep recovery and publication validation in place.

Update generated contracts and regression coverage, including progress
snapshot and execution context expectations and test type annotations.
2026-10-14 17:10:20 +08:00

27 lines
1.1 KiB
Python

"""Presentation gates for the qualified JSON Parse safe-test variant."""
from services.dify_builder.copy_ids import BuilderCopyId
from services.dify_builder.execution_contracts import ExecutionEvidenceSummary
from services.dify_builder.presentation import BuilderText, copy_text
JSON_FAILED_REASON = copy_text(BuilderCopyId.JSON_FAILED)
def json_execution_blocks_repair(summary: ExecutionEvidenceSummary, run_status: str) -> bool:
"""Only a completed, succeeded JSON run may enter ordinary output review."""
return summary.policy_version == "builder-json-parse-v1" and (
summary.safety_outcome != "restricted_execution_completed" or run_status != "succeeded"
)
def json_failed_reason(summary: ExecutionEvidenceSummary | None, run_status: str) -> BuilderText | None:
"""Use fixed copy for a known native failure, never provider error text."""
if (
summary is not None
and summary.policy_version == "builder-json-parse-v1"
and summary.safety_outcome == "native_failed"
and run_status == "failed"
):
return JSON_FAILED_REASON
return None