Repository navigation
test(bedrock): make agentcore invocation tests hermetic after AWS MMDSv2 enforcement - #33280
mateo-berri wants to merge 1 commit into
Conversation
Greptile SummaryThis PR converts three live Bedrock AgentCore invocation tests into hermetic mocked tests after AWS began enforcing MMDSv2 on the CI runtimes, making those tests fail deterministically on every pipeline.
Confidence Score: 4/5Test-only change that strengthens coverage and removes live network dependencies — safe to merge. The rewritten tests are meaningfully more rigorous than the originals: they now assert request shape, auth header format, response content, finish_reason, and token usage. The silent no-op in the SigV4 test is correctly fixed. Two small gaps remain: the AGENTCORE_SSE_BODY fixture omits the final double newline that SSE parsers need to dispatch the last event, and the async streaming path skips the SigV4 header assertion that the sync path includes. Neither gap masks a current regression. tests/llm_translation/test_bedrock_agentcore.py — the SSE fixture terminator and the missing auth assertion in the async streaming test are worth a second look.
|
| Filename | Overview |
|---|---|
| tests/llm_translation/test_bedrock_agentcore.py | Converts three live-invocation tests to hermetic mocked tests, adds SigV4 header assertions, and fixes a conditional-assertion bug; minor SSE fixture formatting gap and missing SigV4 check in the async streaming path. |
Reviews (1): Last reviewed commit: "test(bedrock): make agentcore invocation..." | Re-trigger Greptile
| 'data: {"message":{"role":"assistant","content":[{"text":"Machine learning is pattern matching at scale."}]}}\n' | ||
| ) |
There was a problem hiding this comment.
The last SSE event in
AGENTCORE_SSE_BODY ends with a single instead of the required double `
. SSE parsers delimit events with a blank line (
), so this final {"message":...}event may never be dispatched andfinal_messageremainsNone`. The sync-path tests still pass because content is identically assembled from deltas, but the fixture silently diverges from what AWS actually emits.
| 'data: {"message":{"role":"assistant","content":[{"text":"Machine learning is pattern matching at scale."}]}}\n' | |
| ) | |
| 'data: {"message":{"role":"assistant","content":[{"text":"Machine learning is pattern matching at scale."}]}}\n\n' | |
| ) |
| mock_post.assert_called_once() | ||
| assert mock_post.call_args.kwargs["stream"] is True | ||
| streamed_content = "".join( | ||
| chunk.choices[0].delta.content or "" for chunk in chunks if chunk.choices | ||
| ) | ||
| assert streamed_content == AGENTCORE_ANSWER | ||
| assert any( | ||
| chunk.choices[0].finish_reason == "stop" for chunk in chunks if chunk.choices | ||
| ) |
There was a problem hiding this comment.
test_bedrock_agentcore_with_streaming doesn't assert the Authorization header in the async streaming path. test_bedrock_agentcore_basic (sync path) checks "AWS4-HMAC-SHA256" in headers["Authorization"], but the async streaming path goes through a different code branch (AsyncHTTPHandler) and could regress to Bearer auth without this test catching it.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Closing without merge. The root cause was AWS-side (MMDSv2 disabled on the two CI runtimes) and both runtimes have since been updated with requireMMDSV2=true and verified with live invocations, so the existing tests pass again on their next VCR re-record and CI keeps its live coverage. Full RCA is linked in the PR description |
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Before, captured at
ce3bf2d839(PR #33274): job 2089381 failsllm_translation_testingon the threetest_bedrock_agentcorelive tests, all raisingThis reproduces on every pipeline since 2026-07-14 17:44 UTC regardless of branch content (last green job 2087374 started 17:39 UTC, first red job 2087496 started 17:44 UTC; pipelines 87598 through 87638 all show the identical three failures). AWS now rejects invocations of AgentCore runtimes that do not have MMDSv2 enabled (AWS docs) and both hosted agent runtimes these tests invoke predate that requirement, so they are disabled server-side and no live invocation of them can succeed from any commit until they are updated in AWS
The after proof, captured at
87de8fd5cc, is therefore thellm_translation_testingcheck on this PR going green (job 2089721, success) while the same check is red on every other pipeline since 17:44 UTC. Full RCA with the first-red/last-green bisect and the runtime re-enable runbook: RCA - AWS MMDSv2 enforcement bricked the AgentCore CI runtimesType
✅ Test
Changes
AWS began enforcing MMDSv2 on Bedrock AgentCore runtimes, which turned the three tests in
tests/llm_translation/test_bedrock_agentcore.pythat live-invoke two hand-provisioned runtimes in the CI account into deterministic failures on every pipeline, blocking all PRs on a required checkThis PR rewrites those three tests as mocked invocations that pin the same contract the live calls exercised: the request payload shape (
{"prompt": ...}), SigV4 signing of the request, JSON and SSE response parsing on the sync completion path (including usage extraction from SSE metadata versus the token-counter fallback for JSON bodies), and SSE chunk assembly plus stop signaling on the async streaming pathIt also makes
test_bedrock_agentcore_without_api_key_uses_sigv4deterministic. It previously took the Bearer path wheneverAWS_BEARER_TOKEN_BEDROCKwas set in the runner environment and its Authorization assertions sat inside anif, so it silently asserted nothing; it now clears that env var, passes static test credentials, and asserts the SigV4 signature unconditionallyUpdate: MMDSv2 has since been enabled on both runtimes via
aws bedrock-agentcore-control update-agent-runtimeand real litellm invocations of each (non-streaming and streaming) verified working again, so live coverage can be restored in a follow-up, ideally as a nightly/e2e job rather than a PR-gating check so provider-side lifecycle events cannot block merges again; details in the RCA linked aboveFinal Attestation