SIGN IN SIGN UP

fix(ambient): stop the agent hallucinating tool names; recover from unknown tools (#104)

Ambient cycles always ended 'forced end after 2 attempts' because the agent
could not invoke its tools by name. Two concrete causes:

1. The ambient system prompt and initial message told the agent to use the
   'todos tool', but the real tool is named 'todo'. The model dutifully tried
   'todos' (and, finding nothing, spiraled into 'ToolSearch', 'skill_manage',
   etc.) and never called end_ambient_cycle.

Fixes:
- Correct 'todos' -> 'todo' in the ambient prompt and initial message.
- Add an explicit 'Key tools for this cycle (use these exact names)' block to
  the ambient prompt listing todo / end_ambient_cycle / schedule_ambient /
  request_permission / send_message, and tell the agent there is no tool-search
  tool so it stops trying to discover tools.
- Alias 'todos' -> 'todo' in resolve_tool_name.

2. When the model did guess a wrong name, 'Unknown tool: <x>' gave it nothing
   to recover with, so it kept guessing.

Fix:
- Registry::execute now returns 'Unknown tool: <x>. Did you mean: ...? Available
  tools: ...' listing the session's actual tools and the closest matches. This
  is a general agent-resilience win, not ambient-specific.
- Add a dependency-free closest_tool_names() (prefix/substring + bounded
  Levenshtein) and a small levenshtein() helper.

Tests: suggestion heuristics, the enriched unknown-tool error listing available
tools incl. end_ambient_cycle, and the existing ambient suites stay green.
J
jeremy committed
e4e4a5c1667ffa9bfd44b0163d370bc2e4088b64
Parent: 4a000b8