Skip to content

[BUG] Strands agent calls tool with parameter as dictionary instead of pydantic object #1090

@ruchikaandroid

Description

@ruchikaandroid

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

1.13.0

Python Version

3.11

Operating System

Linux

Installation Method

pip

Steps to Reproduce

SopReviewerArtifact is being used as tool parameter.

response.py ---

UserSelection: TypeAlias = Literal["original", "improved"]

class SopReviewerArtifact(BaseModel):
    original: str
    improved: str
    user_selection: UserSelection

workflow.py ------

  @tool
    def deploy_workflow(
        self,
        sop_reviewer_artifact: SopReviewerArtifact,
        profile_id: str,
        session_id: str,
        sop_name: str,
        version: Optional[int] = None,
    ) -> WorkflowArtifact: 
              .....
             if sop_reviewer_artifact.user_selection == "improved":
                task_description_from_sop = sop_reviewer_artifact.improved
            else:
                task_description_from_sop = sop_reviewer_artifact.original

Expected Behavior

sop_reviewer_artifact is passed as pydantic object and .user_selection succeeds

Actual Behavior

I get the following error meaning sop_reviewer_artifact is being passed as dictionary.

INFO:artemis_profile.tools.workflow:sop_reviewer_artifact {'original': 'for the given image, determine if it is a photograph of a product from the real world (i.e., not CGI/edited/photoshopped) based on one or more of the following aspects. Some signs that indicate an image is from the real-world include: 1) the item is held in hand or placed on a table 2) the item is displayed in front of a realistic background, rather than a solid color.', 'improved': "For the given product image, determine if it is a real-world photograph (not CGI/edited/photoshopped) and output 'Yes' or 'No'. Analyze these indicators of real-world photos:\n\n1. Physical context: Item is held in hand or placed on a table/surface\n2. Background: Realistic environment rather than solid color backdrop\n3. Natural lighting and shadows consistent with real environments\n4. Image grain or noise typical of camera sensors\n5. Natural reflections on product surfaces\n6. Depth of field blur indicating camera optics\n7. Environmental context clues (room settings, outdoor scenes)\n8. Product imperfections or wear indicating real items\n\nApply to all product categories. For uncertain cases, output 'No'.", 'user_selection': 'improved'}
ERROR:artemis_profile.tools.workflow:Error new - 'dict' object has no attribute 'user_selection'
Traceback (most recent call last):
File "/home/ruchikgu/workplace/profiles/env/ArtemisAgentServices-1.0/runtime/lib/python3.11/site-packages/artemis_profile/tools/workflow.py", line 288, in deploy_workflow
reasoning_key = self._create_reasoning_file(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruchikgu/workplace/profiles/env/ArtemisAgentServices-1.0/runtime/lib/python3.11/site-packages/artemis_profile/tools/workflow.py", line 159, in _create_reasoning_file
if sop_reviewer_artifact.user_selection == "improved":
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'user_selection'

Additional Context

No response

Possible Solution

No response

Related Issues

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions