strix/strix/tools/thinking/tool.py
0xallam 48e2cbfe11 Tighten tool surface consistency
Four passes of audit-and-patch on the tool surface, condensed.

Tool API shape:
- Todo tools collapse to a single list-based form (one arg per tool,
  always a list, no dual-mode validator). Result-field names line up
  across the family — created_count / updated_count / marked_count /
  deleted_count, and _mark returns a single "marked" key plus the new
  status instead of marked_done / marked_pending.
- list_notes splits the overloaded total_count into filtered_count
  (matches) and total_count (grand total), matching list_todos. All
  three notes mutations now echo total_count and note_id.
- finish_scan drops the machine-code error strings; a single human
  "error" key carries the reason on every failure path.
- scope_rules delete echoes a message so the renderer's success
  branch has something to surface.

Failure-key unification: every tool now uses {"success": False,
"error": "..."} on failure paths. Touched thinking, web_search,
reporting, and finish. Trailing periods on error strings swept clean
across the whole tool tree.

Tool prompts (docstring re-imports vs main):
- create_vulnerability_report re-imports the CWE reference catalog,
  multi-part fix rules, fix_before/fix_after PR-suggestion mechanics,
  the COMMON MISTAKES list, the informational-vs-actionable
  distinction, and file-path examples.
- web_search re-imports concrete example queries.
- list_sitemap docstring fixed hasDescendants -> has_descendants
  (the camelCase reference never matched our snake_case schema).
- create_agent.skills description "Comma-separated" -> "List of".
- factory.py module docstring no longer claims there's no runtime
  skill-loading tool. agents_graph module docstring lists stop_agent.
- system_prompt nudges loading the matching skill before guessing
  payloads or syntax from memory.

TUI:
- proxy_renderer was reading stale field names from the pre-SDK
  schema (requests / total_count / statusCode / matches /
  showing_lines); now reads entries / page_info / status_code / hits
  / page+total_lines. Three proxy operations were rendering empty
  before this.
- Idle-pane placeholder text trimmed to "Loading...".
2026-05-26 12:16:47 -07:00

37 lines
1.5 KiB
Python

"""``think`` — record a private chain-of-thought note with no side effects."""
from __future__ import annotations
import json
from agents import function_tool
@function_tool(timeout=10)
async def think(thought: str) -> str:
"""Record a private chain-of-thought note. No side effects, no new info.
Use ``think`` when you need a dedicated space to reason before acting —
not as an output channel. It's particularly valuable for:
- **Tool output analysis** — carefully processing the output of a
previous tool call before deciding the next step.
- **Policy-heavy environments** — when you need to follow detailed
guidelines (engagement scope, auth boundaries) and verify compliance
before each action.
- **Sequential decision making** — when each action builds on previous
ones and mistakes are costly (e.g., destructive operations,
irreversible auth changes).
- **Multi-step exploit planning** — breaking down a complex chain into
manageable steps and tracking what's been confirmed vs. assumed.
Structure your thought to be useful: current state, what you've
confirmed, your next planned actions, risk assessment. Don't use
``think`` to chat — use it to plan.
Args:
thought: The reasoning to record. Must be non-empty.
"""
if not thought or not thought.strip():
return json.dumps({"success": False, "error": "Thought cannot be empty"})
return json.dumps({"success": True, "message": "Thought recorded"})