diff --git a/apps/api/src/services/ai_agent_autonomous_runtime_control.py b/apps/api/src/services/ai_agent_autonomous_runtime_control.py index ea66896f8..3bd07ac67 100644 --- a/apps/api/src/services/ai_agent_autonomous_runtime_control.py +++ b/apps/api/src/services/ai_agent_autonomous_runtime_control.py @@ -7178,7 +7178,9 @@ _RUNTIME_VERIFIER_LATEST_SQL = """ evidence.collected_at FROM incident_evidence evidence LEFT JOIN automation_operation_log apply - ON apply.op_id::text = evidence.post_execution_state ->> 'apply_op_id' + ON apply.op_id = CAST( + evidence.post_execution_state ->> 'apply_op_id' AS uuid + ) WHERE evidence.post_execution_state ->> 'apply_op_id' IS NOT NULL ORDER BY evidence.collected_at DESC LIMIT :limit @@ -7221,7 +7223,9 @@ _RUNTIME_VERIFIER_LATEST_DIRECT_SQL = """ evidence.collected_at FROM incident_evidence evidence LEFT JOIN automation_operation_log apply - ON apply.op_id::text = evidence.post_execution_state ->> 'apply_op_id' + ON apply.op_id = CAST( + evidence.post_execution_state ->> 'apply_op_id' AS uuid + ) WHERE evidence.post_execution_state ->> 'apply_op_id' IS NOT NULL ORDER BY evidence.collected_at DESC LIMIT $1 diff --git a/apps/api/tests/test_ai_agent_autonomous_runtime_control.py b/apps/api/tests/test_ai_agent_autonomous_runtime_control.py index 787972bc7..f5b84da1f 100644 --- a/apps/api/tests/test_ai_agent_autonomous_runtime_control.py +++ b/apps/api/tests/test_ai_agent_autonomous_runtime_control.py @@ -1102,6 +1102,9 @@ def test_runtime_receipt_auxiliary_sql_keeps_source_family_counts_schema_safe(): assert "raw_output_stored" in sql assert "independent_post_verifier_passed" in sql assert "LEFT JOIN automation_operation_log apply" in sql + assert "apply.op_id::text" not in sql + assert "apply.op_id = CAST(" in sql + assert "AS uuid" in sql assert "automation_run_id" in runtime_control_module._RUNTIME_KM_LATEST_SQL assert "automation_run_id" in _RUNTIME_TELEGRAM_LATEST_SQL for operation_type in (