Skip to content

feat(shortcuts): add built-in /reset shortcut to wipe local runtime state - #1237

Merged
edenreich merged 13 commits into
mainfrom
fix/issue-1234
Sep 18, 2026
Merged

edenreich merged 13 commits into
mainfrom
fix/issue-1234

Conversation

@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

Resolves #1234

Summary

Adds a built-in /reset shortcut that wipes all local runtime state so the agent starts as if freshly installed, while preserving configuration. It lists every directory it will remove and asks for a y/N-style confirmation (/reset confirm) before deleting anything. The current session is cleared the same way /new does, and remote conversation stores are skipped with a notice instead of an error.

Changes

  • New ResetShortcut (internal/presentation/shortcuts/reset.go):
    • /reset previews the deletion targets and asks for confirmation; only /reset confirm performs the wipe.
    • Deletes and recreates, for every project under ~/.infer/projects/*/: conversations/ plus the per-project runtime dirs (history, backups, tmp, artifacts, exports), and under ~/.infer/: artifacts, plans, tmp, logs.
    • Deletes the configured conversation store: the JSONL conversations dir (default per-project layout, or a custom storage.jsonl.path) or the SQLite database file (storage.sqlite.path or the default ~/.infer/conversations.db, plus its WAL sidecars). Postgres/Redis/D1 get a skip notice instead of an error.
    • Clears the current session the same way /new does (fresh conversation before the wipe, SideEffectStartNewConversation after, so the in-memory repo never re-saves the old conversation into the fresh store).
    • Config (config.yaml), custom shortcuts, skills and projects.json are untouched.
  • Exported the existing dir-name slices from config (config.RuntimeArtifactDirNames, config.UserspaceRuntimeDirNames) and storage.DefaultSQLitePath() so the shortcut reuses them instead of a second hardcoded list.
  • Registered in NewMetadataRegistry (backs /help and infer shortcuts list) and in the chat TUI registry in the container.
  • Tests in reset_test.go: confirm-gated state wipe with config preserved, preview deletes nothing, SQLite db (and WAL sidecars) removed, remote backend skip notice.
  • Docs: /reset entry in README and docs/shortcuts-guide.md.

Notes

  • The sqlite path: a still-open CLI session holds the deleted db inode open until restart; new sessions and other processes see a fresh store, which matches the "deleted" acceptance criterion.
  • No docs ticket: docs were updated in this repo (README, docs/shortcuts-guide.md); a follow-up [DOCS] ticket for the docs repo tracks the docs-repo mirror.

…tate

/reset lists the directories it will remove, asks for confirmation, then wipes every project's conversations, history, backups, tmp, artifacts and exports plus the userspace runtime dirs and logs, reusing the RuntimeArtifactDirNames and UserspaceRuntimeDirNames slices. The configured conversation store is deleted for jsonl (default or custom path) and sqlite (db plus WAL sidecars); remote backends are skipped with a notice. The current session is cleared the same way /new does.
@edenreich
edenreich marked this pull request as ready for review September 18, 2026 11:54
@edenreich
edenreich requested a review from a team as a code owner September 18, 2026 11:54
Comment thread README.md Resolved
Distil past sessions into a markdown report before /reset deletes them:
which workflows repeat often enough to deserve a skill, and which tool
calls keep failing the same way.

Counts and error strings are computed in Go - per-tool totals from
telemetry.Aggregate, failed ToolExecutions folded by normalised error
across every project's sessions - and only the interpretation is left to
one no-tools completion, so the model cannot invent a number. Reports are
written to ~/.infer/insights, which /reset deliberately leaves alone, and
carved out of the sandbox so the agent can read one back when asked to
turn a suggestion into a skill.

/reset insights runs the generator and then previews the wipe without
deleting anything; /insights [since] runs the same generator on its own.

Also fixes long-standing problems in /reset:

- /reset confirm needed no preview, so a tab-completed confirm could wipe
  every project on the machine sight-unseen. It now previews instead,
  and that preview arms the next confirm for five minutes.
- The first removal failure aborted the wipe, leaving the machine half
  cleared with no record of which half. Every target is now attempted and
  the failures are joined.
- The SQLite file was unlinked while this process held it open, so later
  writes went to a deleted inode. Rows are now purged through the store's
  own API first.
- The preview listed targets that did not exist.
- "Proceed (y/N)?" promised a keypress nothing ever read.
- /reset was advertised by /help but only registered when storage was
  enabled.

CustomShortcut.callLLM is lifted to a package-level helper shared with the
insights generator.
An empty "## Analysis" section shipped whenever the model returned no
content: callLLM handed back a successful empty string. A reasoning model
thinks against max_tokens, so it can spend the whole budget and answer
with nothing - the same failure judge.go already guards against. callLLM
now errors and names the token budget when the finish reason is length,
which also covers custom shortcut snippets. The insights budget goes from
2000 to 4000 tokens.

Reports now open with YAML frontmatter recording which model wrote the
analysis and when: generated, model, infer_version, window_since,
sessions, tool_calls, tool_failures, and the full path of every project
covered.
/reset confirm left ~/.infer/{telemetry,schedules,run,tts,voice,media}
behind. targets() built its userspace list only from
config.UserspaceRuntimeDirNames, which cannot simply be extended: that list
doubles as the agent's writable-sandbox allowlist via isWithinRuntimeDirs,
so adding these would hand the agent write access to the telemetry store and
the daemon pid/lock files.

Append them in targets() instead. tts, voice and media go through their
config resolvers so a custom output_dir/recordings_dir/media.dir is wiped
too, not just the default path.
Comment thread docs/directory-structure.md Resolved
@edenreich
edenreich merged commit a08da67 into main Sep 18, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-1234 branch September 18, 2026 13:36
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.203.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add a built-in shortcut /reset

1 participant