Skip to content

Commit ff55c11

Browse files
author
Tirthanu Ghosh
committed
Restore accidentally removed test_retrieve_via_agent_with_enable_metadata
- The test was accidentally removed during the previous commit - Restored the complete test function with both enabled and disabled metadata scenarios - Test passes successfully
1 parent 380f89e commit ff55c11

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/test_retrieve.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,3 +796,26 @@ def test_retrieve_via_agent_with_override_search_type(agent, mock_boto3_client):
796796
knowledgeBaseId="test-kb-id",
797797
retrievalConfiguration={"vectorSearchConfiguration": {"numberOfResults": 10, "overrideSearchType": "HYBRID"}},
798798
)
799+
800+
801+
def test_retrieve_via_agent_with_enable_metadata(agent, mock_boto3_client):
802+
"""Test retrieving via the agent interface with enableMetadata."""
803+
with mock.patch.dict(os.environ, {"KNOWLEDGE_BASE_ID": "agent-kb-id"}):
804+
# Test with metadata enabled
805+
result = agent.tool.retrieve(text="agent query", knowledgeBaseId="test-kb-id", enableMetadata=True)
806+
807+
result_text = extract_result_text(result)
808+
assert "Retrieved" in result_text
809+
assert "results with score >=" in result_text
810+
assert "Metadata:" in result_text
811+
assert "test-source" in result_text
812+
813+
# Test with metadata disabled
814+
with mock.patch.dict(os.environ, {"KNOWLEDGE_BASE_ID": "agent-kb-id"}):
815+
result = agent.tool.retrieve(text="agent query", knowledgeBaseId="test-kb-id", enableMetadata=False)
816+
817+
result_text = extract_result_text(result)
818+
assert "Retrieved" in result_text
819+
assert "results with score >=" in result_text
820+
assert "Metadata:" not in result_text
821+
assert "test-source" not in result_text

0 commit comments

Comments
 (0)