Skip to content

fix: replace deprecated retrieve tool with MemoryManager + BedrockKnowledgeBaseStore - #329

Open
karmendra8386 wants to merge 1 commit into
strands-agents:mainfrom
karmendra8386:fix/308-retrieve-followup
Open

karmendra8386 wants to merge 1 commit into
strands-agents:mainfrom
karmendra8386:fix/308-retrieve-followup

Conversation

@karmendra8386

Copy link
Copy Markdown
Contributor

Follow-up to #308 and #325. #325 swapped the deprecated http_request/shell imports for vended equivalents; these two samples were left out there because retrieve has no vended equivalent — the tools repo deprecation table prescribes MemoryManager + BedrockKnowledgeBaseStore(writable=False) instead. This PR makes that change.

Changes

multi-modal-email-assistant-agent/kb_rag.py

  • retrieve_from_kb() now searches via a MemoryManager backed by a read-only BedrockKnowledgeBaseStore (same KB ID, region, min_score, and 5-result limit as before) and returns the same {status, content: [{text}]} shape its caller already consumes.
  • The analyzer agent receives the memory manager instead of tools=[retrieve]; the env-var configuration the old tool needed is gone.

genai-powered-financial-advisor-tools/application/chat.py

  • The meeting-analysis agent builds a read-only KB store for the per-query KB ID and passes a MemoryManager instead of tools=[retrieve].
  • The manager's search tool keeps the name retrieve, so the existing system prompt ("Use the retrieve tool FIRST…") stays accurate with no prompt changes.

Both use injection=False, so retrieval stays agent-driven through the search tool, matching the old tool's behavior rather than adding automatic context injection.

Verification

  • Both files compile; the store/manager construct against the current SDK (strands-agents 1.57).
  • retrieve_from_kb's return contract exercised locally with a stubbed search (entries joined into content[0].text as the caller expects).
  • Not run end-to-end against a live Bedrock Knowledge Base (no KB available in my environment) — the retrieval call itself is the SDK's maintained Retrieve path.

Out of scope

email_assistant.py in the same sample folder still imports the deprecated editor tool. Happy to include it here or as a separate change, whichever the maintainers prefer.

…wledgeBaseStore

Follow-up to strands-agents#308 (the import-swap PR strands-agents#325 covered http_request/shell;
these two samples needed the real rewrite the deprecation table prescribes
for retrieve: MemoryManager + BedrockKnowledgeBaseStore(writable=False)).

- kb_rag.py: retrieve_from_kb() now searches via MemoryManager and returns
  the same {status, content:[{text}]} contract; the analyzer agent gets
  the manager instead of tools=[retrieve].
- chat.py: the meeting-analysis agent builds a read-only KB store for the
  per-query KB ID and passes a MemoryManager; the search tool keeps the
  name 'retrieve' so the existing system prompt stays accurate.
- Both use injection=False so retrieval stays agent-driven, as before.

Verified locally: both files compile; the manager/store construct against
the current SDK; retrieve_from_kb's return contract exercised with a
stubbed search.
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.

1 participant