refactor(agent_utils.py): remove redundant agent_type parameter from _handle_fallback_response and run_agent_with_retry functions to simplify function signatures

feat(agent_utils.py): retrieve agent_type within _handle_fallback_response to maintain functionality while improving code clarity
This commit is contained in:
Ariel Frischer 2025-02-13 19:16:13 -08:00
parent 5733eb06f5
commit 9caa46bc78
1 changed files with 2 additions and 5 deletions

View File

@ -875,7 +875,6 @@ def _handle_fallback_response(
error: ToolExecutionError,
fallback_handler: Optional[FallbackHandler],
agent: RAgents,
agent_type: str,
msg_list: list,
) -> None:
"""
@ -884,6 +883,7 @@ def _handle_fallback_response(
if not fallback_handler:
return
fallback_response = fallback_handler.handle_failure(error, agent)
agent_type = get_agent_type(agent)
if fallback_response and agent_type == "React":
msg_list_response = [HumanMessage(str(msg)) for msg in fallback_response]
msg_list.extend(msg_list_response)
@ -915,7 +915,6 @@ def run_agent_with_retry(
_max_test_retries = config.get("max_test_cmd_retries", DEFAULT_MAX_TEST_CMD_RETRIES)
auto_test = config.get("auto_test", False)
original_prompt = prompt
agent_type = get_agent_type(agent)
msg_list = [HumanMessage(content=prompt)]
with InterruptibleSection():
@ -941,9 +940,7 @@ def run_agent_with_retry(
logger.debug("Agent run completed successfully")
return "Agent run completed successfully"
except ToolExecutionError as e:
_handle_fallback_response(
e, fallback_handler, agent, agent_type, msg_list
)
_handle_fallback_response(e, fallback_handler, agent, msg_list)
continue
except FallbackToolExecutionError as e:
msg_list.append(