-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtools_think.py
More file actions
68 lines (53 loc) · 2.49 KB
/
tools_think.py
File metadata and controls
68 lines (53 loc) · 2.49 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""Think Tool - Explicit agent reasoning for Dulus.
Provides a Think tool that allows the agent to perform explicit reasoning
without taking any action. The thought is logged and displayed to the user,
helping with transparency and debugging of the agent's decision-making process.
"""
from __future__ import annotations
from tool_registry import ToolDef, register_tool
# ── Schema ────────────────────────────────────────────────────────────────────
_THINK_SCHEMA = {
"name": "Think",
"description": (
"Think about something without taking action. Use this to reason through "
"complex problems, plan your approach, or analyze information before deciding "
"on a tool call. Your thought will be logged and displayed to the user, "
"helping them understand your reasoning process. This tool does NOT modify "
"any state or files."
),
"input_schema": {
"type": "object",
"properties": {
"thought": {
"type": "string",
"description": "A thought to think through. Be detailed and explicit in your reasoning.",
},
},
"required": ["thought"],
},
}
# ── Implementation ────────────────────────────────────────────────────────────
def _think(thought: str) -> str:
"""Log a thought and return a display-friendly result.
Args:
thought: The reasoning text to log.
Returns:
A formatted string with the thought content for display.
"""
# The thought content is returned for display; the model can see its own thought
# and the user can see it via the display block system
prefix = f"[Think] ({len(thought)} characters)"
return f"{prefix}\n\n{thought}"
# ── Registration ──────────────────────────────────────────────────────────────
def _register() -> None:
"""Register the Think tool into the central registry."""
register_tool(
ToolDef(
name="Think",
schema=_THINK_SCHEMA,
func=lambda p, c: _think(p["thought"]),
read_only=True,
concurrent_safe=True,
)
)
_register()