# State and Memory Tools

Tools that search chat, error and action history.

| Tool | Description |
|---|---|
| `chat_history` | This session's own action log. `mode=list` returns recent runs one row each with their `task_id`; `mode=read` opens one or more runs in full — what each was asked for, every tool it called with what came back, and the reply it ended on (`scope=reference` keeps only the expensive payloads, `scope=full` keeps everything); `mode=tool_list` flattens the reusable calls across the last 16 runs so an already-paid-for fetch is found before it is re-run, and `mode=tool` returns one such call's raw output by `task_id` + `name`; `mode=search` searches past messages, `match=semantic` matching meaning in recent messages and `match=keyword` matching text across the full archive (SQLite FTS5, trigram tokenizer), bounded by `time_range`. The records live in the daemon's own store, so file tools never reach them |
| `error_history` | Tool failures kept across sessions. `mode=search` looks up past records by keyword — each carries the fix that worked; `mode=read` fetches one record by its 8-char hash (used when a tool returns `no data: {hash}`); `mode=write` records an error with `tool`, keywords, observed behavior, root cause, what was done, and an `outcome`. Only `outcome=resolved` is stored — `failed` and `abandoned` are accepted but discarded. Search caps at 16 records |
| `reasoning_guide` | Fetch the full rule sets for every topic a turn needs in one call — since v1.0.26 the argument is `topics` (an array, at least one) instead of a single `topic`, and the result joins each guide under a `## <topic>` heading. Topics: `tool_generate`, `tool_error`, `rag_web`, `market_analysis`, `targeted_read`, `ask_user`, `subagent_dispatch`, `write_todo`, `html_render`, `office` (rules for creating or modifying `.docx` / `.xlsx` / `.pptx` so Office and iWork apps accept the file). Replaces the former per-topic guide tools |
| `write_result` | Renamed from `write_report` in v1.0.17, which added HTML output. Saves one long-form deliverable as `report-YYYYMMDD-HHMMSS.md` or `.html` in the output directory and returns the write receipt with its path — the research / analysis / comparison body the reply summarises instead of reprinting, or a finished HTML page. `content` is the complete file; `format` is `md` (default) or `html`. The output directory is `output_dir` from `config.json` (set with `/config`), else `~/Downloads` when it exists, else `~/.config/agenvoy/download/`. Any other file, or a change to a file that already exists → `edit_file` |
