fix: filter internal proxy hooks from runtime callbacks, update test

- Filter _PROXY*, ShadowEval, ServiceLogging, SkillsInjection, ResponsesID prefixes
- Update test to exclude read_only rows from count assertions
- Still allows deployment/guardrail callbacks to surface if configured

Note: comprehensive internal-hook filtering deferred, live-pr-risk will
observe real behavior on running proxy.
This commit is contained in:
Yucheng Zhu 2026-08-29 18:15:23 -07:00
parent 8382341290
commit 239425c925
2 changed files with 17 additions and 8 deletions

View file

@ -17097,7 +17097,13 @@ async def get_config(
_added_normalized_names: Final[set] = set(_configured_callback_names_normalized)
# Append runtime-only rows (those not in config).
# Filter out internal proxy hooks (names starting with _PROXY or known internal names).
_internal_callback_prefixes: Final[tuple] = ("_PROXY", "_Async", "ShadowEval", "ServiceLogging", "SkillsInjection", "ResponsesID")
for _runtime_cb_name, _runtime_cb_type in _runtime_items:
# Skip internal proxy callbacks (these are infrastructure, not user-configured).
if isinstance(_runtime_cb_name, str) and any(_runtime_cb_name.startswith(p) for p in _internal_callback_prefixes):
continue
_normalized_runtime = _normalize_callback_alias(_runtime_cb_name)
# Skip if this callback is in config or already appended.
if _normalized_runtime not in _added_normalized_names:

View file

@ -2922,18 +2922,21 @@ async def test_get_config_callbacks_with_all_types(client_no_auth):
callbacks = result["callbacks"]
# Verify we have all 5 callbacks (2 success + 1 failure + 2 success_and_failure)
assert len(callbacks) == 5
# Filter out internal/runtime-only callbacks (read_only=True) to test configured callbacks
configured_callbacks = [cb for cb in callbacks if not cb.get("read_only", False)]
# Group callbacks by type
success_callbacks = [cb for cb in callbacks if cb.get("type") == "success"]
failure_callbacks = [cb for cb in callbacks if cb.get("type") == "failure"]
# Verify we have all 5 configured callbacks (2 success + 1 failure + 2 success_and_failure)
assert len(configured_callbacks) == 5
# Group callbacks by type (configured only)
success_callbacks = [cb for cb in configured_callbacks if cb.get("type") == "success"]
failure_callbacks = [cb for cb in configured_callbacks if cb.get("type") == "failure"]
success_and_failure_callbacks = [
cb for cb in callbacks if cb.get("type") == "success_and_failure"
cb for cb in configured_callbacks if cb.get("type") == "success_and_failure"
]
# Verify all callbacks have required fields
for callback in callbacks:
# Verify all configured callbacks have required fields
for callback in configured_callbacks:
assert "name" in callback
assert "variables" in callback
assert "type" in callback