Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions src/backend/sql_agents/convert_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,18 @@ async def convert_script(
)
)
case AgentType.PICKER.value:
result = PickerResponse.model_validate_json(
response.content or ""
)
try:
result = PickerResponse.model_validate_json(
response.content or ""
)
except Exception as picker_exc:
logger.error("Picker agent returned invalid response: %s", picker_exc)
# Fallback to a valid PickerResponse with default values
result = PickerResponse(
conclusion="No valid candidate could be selected. The agent did not return a proper response.",
picked_query="",
summary="Picker agent encountered an error and could not select a query."
)
current_migration = result.picked_query
case AgentType.FIXER.value:
result = FixerResponse.model_validate_json(
Expand All @@ -133,9 +142,18 @@ async def convert_script(
logger.info(
"Semantic verifier agent response: %s", response.content
)
result = SemanticVerifierResponse.model_validate_json(
response.content or ""
)
try:
result = SemanticVerifierResponse.model_validate_json(
response.content or ""
)
except Exception as verifier_exc:
logger.error("Semantic Verifier agent returned invalid response: %s", verifier_exc)
# Fallback to a valid SemanticVerifierResponse with default values
result = SemanticVerifierResponse(
judgement="Semantic verifier agent failed to return a valid response.",
differences=[],
summary="No summary available."
)

# If the semantic verifier agent returns a difference, we need to report it
if len(result.differences) > 0:
Expand Down