Repository navigation
fix(memory): allow RetrievalConfig top_k=1 (ge=1, not gt=1) - #728
Open
PratikDhanave wants to merge 1 commit into
Open
PratikDhanave wants to merge 1 commit into
PratikDhanave wants to merge 1 commit into
Conversation
RetrievalConfig.top_k used Field(gt=1), which rejects top_k=1 — a legitimate request for the single best-scoring record. The SDK itself calls retrieve_memories(..., top_k=1) (client.py), and RetrievalConfig is a public parameter of MemorySessionManager.process_turn_with_llm, so a caller passing top_k=1 hits pydantic ValidationError. The upper bound is already inclusive (le=100); make the lower bound inclusive too. Add a regression test.
PratikDhanave
requested a deployment
to
manual-approval
November 2, 2026 13:53 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 2, 2026 13:53 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 2, 2026 13:53 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 2, 2026 13:53 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 2, 2026 13:53 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 2, 2026 13:53 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 2, 2026 13:53 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 2, 2026 13:53 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 2, 2026 13:53 — with
GitHub Actions
Waiting
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RetrievalConfig.top_kusedField(default=10, gt=1, le=100), which rejectstop_k=1— a legitimate request for the single best-scoring record.Why it matters
self.retrieve_memories(..., top_k=1)(memory/client.py), andRetrievalConfigis a public parameter ofMemorySessionManager.process_turn_with_llm, so a caller passingtop_k=1hitspydantic.ValidationError: Input should be greater than 1.le=100); the lower bound should be too.Fix
Testing
Added
test_retrieval_config_top_k_allows_one:RetrievalConfig(top_k=1)must be accepted, whiletop_k=0andtop_k=101still raise.top_k=1raisesValidationError(test fails).pytest tests/bedrock_agentcore/memory/test_session.py→ 157 passed.Developed with AI assistance (Claude Code): the off-by-one bound was located, the fix applied, and the regression test written and run locally. I reviewed and verified the change and take responsibility for it.