Skip to content

Commit 8a150db

Browse files
author
Shreyas-Microsoft
committed
fix bug
1 parent 3d7d571 commit 8a150db

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/backend/sql_agents/convert_script.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,18 @@ async def convert_script(
120120
)
121121
)
122122
case AgentType.PICKER.value:
123-
result = PickerResponse.model_validate_json(
124-
response.content or ""
125-
)
123+
try:
124+
result = PickerResponse.model_validate_json(
125+
response.content or ""
126+
)
127+
except Exception as picker_exc:
128+
logger.error("Picker agent returned invalid response: %s", picker_exc)
129+
# Fallback to a valid PickerResponse with default values
130+
result = PickerResponse(
131+
conclusion="No valid candidate could be selected. The agent did not return a proper response.",
132+
picked_query="",
133+
summary="Picker agent encountered an error and could not select a query."
134+
)
126135
current_migration = result.picked_query
127136
case AgentType.FIXER.value:
128137
result = FixerResponse.model_validate_json(
@@ -133,9 +142,18 @@ async def convert_script(
133142
logger.info(
134143
"Semantic verifier agent response: %s", response.content
135144
)
136-
result = SemanticVerifierResponse.model_validate_json(
137-
response.content or ""
138-
)
145+
try:
146+
result = SemanticVerifierResponse.model_validate_json(
147+
response.content or ""
148+
)
149+
except Exception as verifier_exc:
150+
logger.error("Semantic Verifier agent returned invalid response: %s", verifier_exc)
151+
# Fallback to a valid SemanticVerifierResponse with default values
152+
result = SemanticVerifierResponse(
153+
judgement="Semantic verifier agent failed to return a valid response.",
154+
differences=[],
155+
summary="No summary available."
156+
)
139157

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

0 commit comments

Comments
 (0)