Skip to content

[FEATURE] Pass tool use id into a @tool-decortated tools #194

@Lou1415926

Description

@Lou1415926

Problem Statement

Today, if we define a module-based tool (that requires TOOL_SPEC), the tool use id is passed into the tool as a part of the tool: ToolUse parameter.

This parameter isn't available in a @tool-decorated tool, which means it is impossible for a @tool-decorated tool to access the same information that's available in the module-based counterpart.

(Originally posted at https://github.com/strands-agents/tools/issues, but I figured this repo is the more appropriate place for this issue)

Proposed Solution

No response

Use Case

Why do I need tool use id?

My tool needs to write to a global storage in my agent app, preferably indexed with tool use id.

Why do I not use module-based tool?

It is harder to pass a global storage into my tool if it is a module-based tool. )Perhaps this is due to my lack of knowledge when it comes to python modules though!)

With @tool-decorated, I could do

def create_my_ask_human_tool(global_storage: Storage) -> Callable:
   @tool
   def my_ask_human_tool():
       global_storage.add(something)

  return my_ask_human_tool


def create_agent(global_storage: Storage):
    my_ask_human_tool = create_my_ask_human_tool(global_storage)
    my_agent = strands.Agent(custom_tools=[my_ask_human_tool])

Alternatives Solutions

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions