Skip to content

translator: map Bedrock guardrail_intervened to finish_reason content_filter - #2897

Open
pcbeingused333 wants to merge 2 commits into
theagentrouter:mainfrom
pcbeingused333:fix/bedrock-guardrail-finish-reason
Open

pcbeingused333 wants to merge 2 commits into
theagentrouter:mainfrom
pcbeingused333:fix/bedrock-guardrail-finish-reason

Conversation

@pcbeingused333

Copy link
Copy Markdown

Description

bedrockStopReasonToOpenAIStopReason maps content_filtered to content_filter but not guardrail_intervened (awsbedrock.StopReasonGuardrailIntervened is defined and unused), so a Bedrock Guardrails block falls to the default and looks like a normal stop to OpenAI-API clients. This adds it to the content_filtered case; the function is used by both the streaming and the non-streaming path.

TestBedrockStopReasonToOpenAIStopReason is a table test over the known stop reasons; the guardrail intervened row fails on main (stop instead of content_filter) and passes here.

This PR was prepared with an AI coding assistant (Claude Code), and the submitter is responsible for it.

Related Issues/PRs (if applicable)

None found: no open issue or PR on this stop reason.

Special notes for reviewers (if applicable)

go test ./internal/translator/ (whole package) passes with Go 1.27.2; make precommit was not run.

…_filter

bedrockStopReasonToOpenAIStopReason handled content_filtered but not guardrail_intervened, which fell to the default and was reported as a normal stop. A Bedrock Guardrails block now finishes with content_filter for OpenAI-API clients, in both the streaming and the non-streaming path.

Signed-off-by: Alex Castillo <alex.castillog33@gmail.com>
@pcbeingused333
pcbeingused333 requested a review from a team as a code owner October 21, 2026 03:07
@netlify

netlify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for theagentrouter canceled.

Name Link
🔨 Latest commit b85feae
🔍 Latest deploy log https://app.netlify.com/projects/theagentrouter/deploys/6af0909f0c7565032ab9a0e2

@gavrissh gavrissh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change!

@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pcbeingused333

pcbeingused333 commented Oct 31, 2026 •

Copy link
Copy Markdown
Author

@gavrissh thanks for the approval on the 27th. The branch is still mergeable with main; the only red check is E2E Test for Upgrades (k8s v1.34.3) (and ci-required that aggregates it). Is that one expected to be flaky, or would you like me to look into it before this can go in?

This comment was drafted with Claude Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants