FIX Redundant code block in run_agent_with_retry

This commit is contained in:
Jose Leon 2025-03-11 02:53:05 +00:00
parent 9f3e6b9ae8
commit 0ae6bea9d5
1 changed files with 13 additions and 14 deletions

View File

@ -697,22 +697,21 @@ def run_agent_with_retry(
return f"Agent has crashed: {crash_message}"
try:
# Ensure messages have thinking blocks if needed before each run
# Check if we need to ensure thinking blocks
config = get_config_repository().get_all()
if is_anthropic_claude(config):
provider = config.get("provider", "")
model_name = config.get("model", "")
provider = config.get("provider", "")
model_name = config.get("model", "")
# Only apply to Claude 3.7 models with thinking enabled
if (provider.lower() == "anthropic" and
"claude-3-7" in model_name.lower() and
not config.get("disable_thinking", False)):
# Only apply to Claude 3.7 models with thinking enabled
if (provider.lower() == "anthropic" and
"claude-3-7" in model_name.lower() and
not config.get("disable_thinking", False)):
# Get model configuration to check if thinking is supported
model_config = models_params.get(provider, {}).get(model_name, {})
if model_config.get("supports_thinking", False):
logger.debug("Ensuring thinking blocks for Claude 3.7 before agent run")
msg_list = _ensure_thinking_block(msg_list, config)
# Get model configuration to check if thinking is supported
model_config = models_params.get(provider, {}).get(model_name, {})
if model_config.get("supports_thinking", False):
logger.debug("Ensuring thinking blocks for Claude 3.7 before agent run")
msg_list = _ensure_thinking_block(msg_list, config)
_run_agent_stream(agent, msg_list)
if fallback_handler: