fix: log warnings on silently swallowed agent and endpoint failures (#2367)

get_builtin_overrides() was swallowing all exceptions with a bare
`except Exception: pass`, so misconfigured tool-description overrides
would silently produce wrong agent behaviour with no log trace.

The background endpoint refresh loop had the same pattern: any probe
failure was silently ignored, giving operators no signal that the
refresh was broken.

Also removes a circular self-import (`from src.agent_loop import
_build_base_prompt`) inside _build_system_prompt; the function is
already in scope and the import created a latent circular reference risk.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Giuseppe
2026-06-04 13:29:31 +02:00
committed by GitHub
parent d25052e43f
commit f6a5f6592f
2 changed files with 5 additions and 5 deletions

View File

@@ -993,8 +993,8 @@ def setup_model_routes(model_discovery):
db.close()
if changed:
_invalidate_models_cache()
except Exception:
pass
except Exception as e:
logger.warning('Background endpoint refresh failed: %s', e)
finally:
for st in _refresh_state.values():
st["inflight"] = False

View File

@@ -375,7 +375,8 @@ def get_builtin_overrides() -> dict:
from src.settings import get_setting
ov = get_setting("builtin_tool_overrides", {})
return ov if isinstance(ov, dict) else {}
except Exception:
except Exception as e:
logger.warning('Failed to load builtin tool overrides: %s', e)
return {}
@@ -611,8 +612,7 @@ def _build_system_prompt(
# Skill index is user-editable (name + description), so it must never
# live in the trusted system role and is NOT cached. Always recompute
# when the cache hits.
from src.agent_loop import _build_base_prompt as _bbp_recompute
_, _skill_index_block = _bbp_recompute(
_, _skill_index_block = _build_base_prompt(
disabled_tools, mcp_mgr, needs_admin, relevant_tools,
mcp_disabled_map=mcp_disabled_map, compact=compact,
)