fix: ComprehendFilterAgent client initialization and on_llm_start docstring#437
Open
abhu85 wants to merge 1 commit intoawslabs:mainfrom
Open
fix: ComprehendFilterAgent client initialization and on_llm_start docstring#437abhu85 wants to merge 1 commit intoawslabs:mainfrom
abhu85 wants to merge 1 commit intoawslabs:mainfrom
Conversation
…string Issue awslabs#359: Fixed bug where ComprehendFilterAgent incorrectly assigned boto3 client to self.client instead of self.comprehend_client when no client was provided. This caused an AttributeError when calling process_request on an agent initialized without explicit client. Issue awslabs#360: Fixed docstring for on_llm_start callback method: - Changed 'agent_name' to 'name' to match actual parameter - Removed non-existent 'messages' parameter from docs - Updated context from 'agent' to 'LLM' for consistency Added regression test to verify comprehend_client is properly set when agent is initialized without an explicit client. Fixes awslabs#359 Fixes awslabs#360 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
This PR fixes two bugs reported in issues #359 and #360:
Issue #359 - ComprehendFilterAgent missing client initialization
When creating a
ComprehendFilterAgentwithout passing an explicit client (relying on boto3 to create one), the agent would fail withAttributeError: 'ComprehendFilterAgent' object has no attribute 'comprehend_client'.Root cause: Lines 34 and 39 in
comprehend_filter_agent.pyincorrectly assigned the boto3 client toself.clientinstead ofself.comprehend_client.Fix: Changed
self.clienttoself.comprehend_clientin both branches of the initialization logic.Issue #360 - Documentation bug in on_llm_start callback
The docstring for
on_llm_startinagent.pydocumented parameters that didn't match the actual method signature:agent_name(should bename)messages(not a parameter of this method)Fix: Updated docstring to accurately reflect the method signature and context (LLM vs agent).
Test plan
test_initialization_without_client_uses_comprehend_clientto verifycomprehend_clientis properly set when initializing without explicit clienttest_comprehend_agent.pypassReproduction (Issue #359)
Before this fix, the following code would fail:
After this fix, the agent correctly initializes and processes requests.
Fixes #359
Fixes #360