AI_Forum / UPGRADE_NOTES.md
Haster1137's picture
Upload 6 files
56ca19b verified
|
Raw History Blame Contribute Delete
6.36 kB

local_agent.py — what changed in this refactor

Everything is still one file. python local_agent.py --serve works exactly as before; nothing new has to be installed for the script to run.

Self-test: 73 passed, 0 failed (python local_agent.py --selftest). The version you sent reported 70 passed, 2 failed — see "Bugs fixed" below.


1. Web search now goes through your local SearXNG

Box/tools/searxng is wired in as the real search backend.

  • Health-checked and started on demand if it is not already running — launched from its own venv, with your settings.yml, no console window, and it does not die when you Ctrl+C the agent window.
  • Results come back as structured JSON across all your enabled engines instead of being scraped out of a results page.
  • DuckDuckGo Lite is kept as a fallback, so search still works if SearXNG is down.

New settings (Settings → Web search):

setting meaning
search_backend auto (SearXNG, fall back to DDG), searxng (strict), duckduckgo
searxng_url default http://127.0.0.1:8888
searxng_dir where settings.yml, src\, venv\ live
searxng_autostart launch it in the background when a search needs it
searxng_engines optional restriction, e.g. google,wikipedia; blank uses settings.yml

The settings panel shows whether the instance is up and has a Start it now button.


2. Thirteen new tools (33 total, up from 20)

Web — search_news, search_images, download_file, http_request, search_status

Images — make_logo, render_svg, make_icon_set, image_info, sd_image

Code — find_in_files, run_python, check_syntax, pip_install

Utility — current_time, calculate, remember, recall

remember / recall keep an AGENT_NOTES.md in the workspace, so decisions and constraints survive between sessions.

The tool index in the system prompt is still one line per tool, so the extra tools cost very little prompt.


3. Image generation, built for a CPU-only box

Vector first: the model either writes SVG itself (render_svg) or parameterises a mark (make_logo), and the script rasterises it. That is instant on your i9 — a diffusion model would not be.

  • make_logo — 8 palettes, shapes circle | rounded | square | hexagon | shield | none, styles solid | outline | gradient, optional tagline, monogram derived from the name or overridden.
  • make_icon_set — cuts favicon/app-icon sizes and writes a real multi-size favicon.ico.
  • PNG conversion tries cairosvg → svglib → Pillow, whichever is installed. With none of them the .svg is still written and the tool says so. Pillow alone was enough on test; pip install cairosvg gives the best fidelity for model-authored SVG.
  • sd_image only works if you point sd_url at a running Stable Diffusion WebUI (/sdapi/v1/txt2img). Blank by default, and when blank it tells the model to use the vector route instead of retrying.

Generated images preview inline in the tool card that made them, served read-only from the new /workspace/<path> route (path traversal is blocked).

Output lands in generated/ inside the workspace — change with image_dir.


4. The system prompt is one document, not three

Rewritten as an ordered procedure in eight numbered sections: the contract, how a turn runs, using tools, files and code, searching the web, making images, how you write, and stopping. The three stapled-together drafts (and their typos) are gone.

The headline rule is first and unambiguous: do what was asked, all of it, nothing adjacent, and never claim a result you did not receive.

PROTOCOL (the agent-mode block) was rewritten too and now ends with a tool-picking table, so the model matches an intent to a tool instead of guessing.


5. Loop discipline — the anti-spiral guard

Prompt wording alone does not stop a local model from thrashing, so this is enforced in the loop:

  • The same tool with the same arguments past repeat_call_limit (default 2) is refused without running, and the model is told to change approach or answer with what it has.
  • After failure_streak_limit (default 4) consecutive failures, it is told to stop calling tools and report the blocker.

Both are in Settings → Loop discipline. Tested end-to-end against a deliberately stuck model: two calls run, every repeat after that is refused for almost no tokens.


6. Voice: dictation in, read-aloud out

Both run in the browser — no extra Python, no services.

  • Mic button in the composer (or Ctrl+Shift+M). Interim text appears as you talk, it restarts itself through pauses so a thinking gap does not end dictation, and saying "send it" fires the turn.
  • Read aloud toggle in the top bar (Ctrl+Shift+S) speaks every answer as it finishes; every answer also gets its own Read aloud and Copy button. Esc stops speech.
  • Settings → Voice picks the voice and speed from whatever Windows has installed.

Worth knowing: speech synthesis is fully offline (Windows SAPI voices). Dictation uses Chrome/Edge's recogniser, which uploads the audio to the browser vendor to transcribe. The settings panel says so plainly. If that matters, type instead — everything else in this app stays on your machine.


Bugs fixed

  1. split_thinking had saw_open initialised inverted (not inside instead of inside). That silently disabled the retag signal in exactly the prefill case it exists for, so reasoning leaked into the answer pane during normal runs. This was the cause of both failing self-tests.
  2. Stray module-level demo code between the tool registry and DISABLED_TOOLS ran a hard-coded path check and printed Access denied: ... on every import. Removed; is_within_directory is now a real function that also handles Windows cross-drive paths.
  3. search_status's fallback line claimed DuckDuckGo was available even when search_backend forbade it.

Optional, not required

pip install cairosvg     # best SVG -> PNG fidelity (Pillow fallback works)
pip install pillow       # PNG output and icon resizing, if not already there

Use Chrome or Edge for the microphone; Firefox has no speech recognition.