forked from strands-agents/harness-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandoff_to_user.py
More file actions
34 lines (28 loc) · 883 Bytes
/
Copy pathhandoff_to_user.py
File metadata and controls
34 lines (28 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from rich.markup import escape
from rich.panel import Panel
from strands import tool
from strands.types.tools import ToolContext
from strands_tools.utils import console_util
@tool(context=True)
def handoff_to_user(message: str, tool_context: ToolContext) -> str:
"""
Hand off control to the user with a message.
Args:
message: The message to give to the user
Returns:
The users response after handing back control
"""
console = console_util.create()
console.print(
Panel(
escape(message),
title="[bold yellow]🤝 Handoff to User",
border_style="yellow",
)
)
request_state = {
"stop_event_loop": True
}
tool_context.invocation_state["request_state"] = request_state
# Return an empty string as this will break out of the event loop
return ""