fix(pass-through): Normalize Bedrock agent runtime routes to not require trailing slashes

This commit is contained in:
OpenClaw 2026-02-14 00:56:19 +00:00
parent ab4b6197ef
commit dde18dd9d7
3 changed files with 24 additions and 9 deletions

View file

@ -1197,13 +1197,13 @@ PYTHON_GC_THRESHOLD = os.getenv("PYTHON_GC_THRESHOLD")
# pass through route constansts
BEDROCK_AGENT_RUNTIME_PASS_THROUGH_ROUTES = [
"agents/",
"knowledgebases/",
"flows/",
"retrieveAndGenerate/",
"rerank/",
"generateQuery/",
"optimize-prompt/",
"agents",
"knowledgebases",
"flows",
"retrieveAndGenerate",
"rerank",
"generateQuery",
"optimize-prompt",
]

View file

@ -1174,10 +1174,14 @@ def _resolve_vertex_model_from_router(
def _is_bedrock_agent_runtime_route(endpoint: str) -> bool:
"""
Return True, if the endpoint should be routed to the `bedrock-agent-runtime` endpoint.
Return True if the endpoint should be routed to the `bedrock-agent-runtime` endpoint.
Uses normalized path segments so trailing slashes are not required.
"""
normalized = endpoint.strip("/")
parts = normalized.split("/")
for _route in BEDROCK_AGENT_RUNTIME_PASS_THROUGH_ROUTES:
if _route in endpoint:
if _route in parts:
return True
return False

View file

@ -419,6 +419,17 @@ def test_is_bedrock_agent_runtime_route():
)
assert _is_bedrock_agent_runtime_route("/some/random/endpoint") is False
# Test endpoints without trailing slashes still match
assert _is_bedrock_agent_runtime_route("agents") is True
assert _is_bedrock_agent_runtime_route("knowledgebases") is True
assert _is_bedrock_agent_runtime_route("flows") is True
assert _is_bedrock_agent_runtime_route("/agents") is True
assert _is_bedrock_agent_runtime_route("/knowledgebases/") is True
# Test that partial segment matches do NOT match (no substring false positives)
assert _is_bedrock_agent_runtime_route("/myagents/foo") is False
assert _is_bedrock_agent_runtime_route("/someflows/bar") is False
def test_init_kwargs_filters_pricing_params(mock_request, mock_user_api_key_dict):
"""