Skip to content

Commit 873b82b

Browse files
committed
Switch test to passing a reference
1 parent dd88670 commit 873b82b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/strands/tools/test_decorator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Tests for the function-based tool decorator pattern.
33
"""
44

5+
from asyncio import Queue
56
from typing import Any, Dict, Optional, Union
67
from unittest.mock import MagicMock
78

@@ -1075,14 +1076,16 @@ async def _run_context_injection_test(context_tool: AgentTool, additional_contex
10751076
async def test_tool_context_injection_default():
10761077
"""Test that ToolContext is properly injected with default parameter name (tool_context)."""
10771078

1079+
value_to_pass = Queue() # a complex value that is not serializable
1080+
10781081
@strands.tool(context=True)
10791082
def context_tool(message: str, agent: Agent, tool_context: ToolContext) -> dict:
10801083
"""Tool that uses ToolContext to access tool_use_id."""
10811084
tool_use_id = tool_context.tool_use["toolUseId"]
10821085
tool_name = tool_context.tool_use["name"]
10831086
agent_from_tool_context = tool_context.agent
10841087

1085-
assert tool_context.invocation_state["new_value"] == 13
1088+
assert tool_context.invocation_state["test_reference"] is value_to_pass
10861089

10871090
return {
10881091
"status": "success",
@@ -1096,7 +1099,7 @@ def context_tool(message: str, agent: Agent, tool_context: ToolContext) -> dict:
10961099
await _run_context_injection_test(
10971100
context_tool,
10981101
{
1099-
"new_value": 13,
1102+
"test_reference": value_to_pass,
11001103
},
11011104
)
11021105

0 commit comments

Comments
 (0)