Skip to content

Commit d0a514e

Browse files
committed
strands argument passing update
1 parent d2c6c11 commit d0a514e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/idp_common_pkg/idp_common/assessment/strands_tools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def submit_assessment(assessment: AssessmentOutput, agent: Agent) -> str:
5454
Success confirmation message or validation error details
5555
"""
5656
# Validate assessment structure and return helpful errors
57-
validated_assessment = AssessmentOutput(**assessment) # pyright: ignore[reportCallIssue]
57+
validated_assessment = AssessmentOutput.model_validate(assessment)
5858

5959
# Store in agent state
6060
agent.state.set("assessment_output", validated_assessment.model_dump())
@@ -80,7 +80,7 @@ def create_view_image_tool(page_images: list[bytes], sorted_page_ids: list[str])
8080
"""
8181

8282
@tool
83-
def view_image(input_data: dict[str, Any], agent: Agent) -> dict:
83+
def view_image(input_data: ViewImageInput, agent: Agent) -> dict:
8484
"""
8585
View a specific page image, optionally highlighting a bounding box area.
8686
@@ -104,7 +104,7 @@ def view_image(input_data: dict[str, Any], agent: Agent) -> dict:
104104
}, agent)
105105
"""
106106
# Validate input - let ValidationError propagate
107-
view_input = ViewImageInput(**input_data)
107+
view_input = ViewImageInput.model_validate(input_data)
108108

109109
# Validate image index exists
110110
if view_input.image_index >= len(page_images):

lib/idp_common_pkg/idp_common/extraction/agentic_idp.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ def extraction_tool(
223223
This tool needs to be Successfully invoked before the patch tool can be used."""
224224

225225
logger.info("extraction_tool called", extra={"models_extraction": extraction})
226-
extraction_model = model_class(**extraction) # pyright: ignore[reportAssignmentType]
226+
# Note: The @tool decorator passes data as a dict, not as a model instance
227+
# We need to validate it manually using the Pydantic model
228+
extraction_model = model_class.model_validate(extraction) # pyright: ignore[reportAssignmentType]
227229
extraction_dict = extraction_model.model_dump()
228230
agent.state.set(key="current_extraction", value=extraction_dict)
229231
logger.debug(
@@ -263,7 +265,9 @@ def apply_json_patches(
263265

264266
@tool
265267
def make_buffer_data_final_extraction(agent: Agent) -> str:
266-
valid_extraction = model_class(**agent.state.get("intermediate_extraction"))
268+
valid_extraction = model_class.model_validate(
269+
agent.state.get("intermediate_extraction")
270+
)
267271

268272
agent.state.set("current_extraction", valid_extraction.model_dump())
269273

0 commit comments

Comments
 (0)