- Use main model instead of fast model for background reviews — the
judgment about what's worth saving benefits from full model quality
- Always include memory tools when skill review fires — complex work
often surfaces environment facts worth remembering
- Strengthen review prompts with explicit USER vs MEMORY targeting,
priority ranking, de-duplication rules, and concrete examples
- Enrich the review system prompt with the same guidance quality as
the tool descriptions
Signed-off-by: Michael Neale <michael.neale@gmail.com>
* origin/main:
move agent skills to repo root for tool discoverability (#8535)
port goose2 chat attachments into goose (#8534)
chore(release): bump version to 1.31.0 (minor) (#8527)
feature: provider & model config (#8515)
Move goose2 (#8516)
feat: onboarding UX for the TUI (#8513)
Set MACOSX_DEPLOYMENT_TARGET=12.0 in build-cli.yml (#8525)
Improve local inference settings and model downloader (#8467)
Add prompt injection mitigation logging back (#8518)
feat(providers): add llama-swap declarative provider (#8462)
fix: Unable to Run `goose update` on Linux (#8465)
Add vision/image support for local inference models (#8442)
When adaptive_memory is off, compaction behaves identically to main —
no tool result pruning, no flush, no background review. All adaptive
behaviors are now conditional on the extension being enabled.
Signed-off-by: Michael Neale <michael.neale@gmail.com>
Extract handle_create_skill and handle_patch_skill from SkillsClient
methods into pub free functions in skills.rs. Add create_skill and
patch_skill tool definitions and dispatch to AdaptiveMemoryClient,
so these tools are only available when adaptive memory is enabled.
Skills extension now only exposes load_skill. Tests updated to call
free functions directly. Knowledge review test data updated to use
adaptive_memory__ prefix for skill mutation tools.
Signed-off-by: Michael Neale <michael.neale@gmail.com>
- adaptive_memory: default_enabled false (opt-in via extension manager)
- Revert compaction threshold to 0.8 (was 0.5, separate concern)
- Remove SOUL.md persona feature (orthogonal, not ready)
When adaptive_memory is off, background review and flush self-gate:
they check for memory/skill tools and no-op when none found.
So off = behaves like before. On = full Hermes-style behavior.
Signed-off-by: Michael Neale <michael.neale@gmail.com>
Address critical findings from GPT-5.4 code review:
1. Memory read-modify-write race: add with_exclusive_entries() that holds
a single exclusive lock for the entire read-modify-write cycle, matching
Hermes's _file_lock pattern. All three operations (add/replace/remove)
now use this instead of separate read_entries_locked + write_entries.
2. Review trigger never reset: was using turns_taken (per-reply loop counter)
which fires every turn after threshold. Now uses AtomicU32 counter on
Agent that increments per user turn and resets to 0 after firing,
matching Hermes's _turns_since_memory pattern.
Signed-off-by: Michael Neale <michael.neale@gmail.com>
- Simplify knowledge_review threshold tests to use assert_eq! instead
of assert! on constant expressions (clippy::assertions_on_constants)
- Re-record all_platform_extensions snapshot without local Block skills
so it matches CI environment (only goose-doc-guide)
Signed-off-by: Michael Neale <michael.neale@gmail.com>
Background review now queries the SQLite session history via
search_chat_history before running the extraction. Recent sessions
(up to 3, excluding current) are summarized and appended to the
review prompt as context.
This lets the review agent notice cross-session patterns:
- 'user corrected me about X in multiple sessions'
- 'this tool quirk keeps coming up'
- 'user always prefers Y approach'
Uses the existing ChatHistorySearch infrastructure — no new
dependencies or schema changes needed.
Signed-off-by: Michael Neale <michael.neale@gmail.com>
The Hermes-style adaptive memory (USER.md, MEMORY.md, § delimiters,
hard budgets, security scanning) is now a platform extension called
'adaptive_memory' — runs in-process like skills, default-enabled,
with unprefixed 'memory' tool.
The original MCP memory server is restored unchanged. Users who had
the 'memory' builtin extension configured keep the old category-based
system. The new adaptive_memory extension runs alongside it — both
can coexist since they use different tool names (the old one has
remember_memory/retrieve_memories/etc, the new one has a single
'memory' tool with action param).
This means:
- No breaking change for existing memory users
- New adaptive learning is available by default for everyone
- Old MCP memory can still be enabled for project-scoped/categorized storage
- Background review and flush use the new platform extension's tool
Signed-off-by: Michael Neale <michael.neale@gmail.com>
External skills from ~/.agents/, .claude/, .agents/ etc are now
read-only to the agent. patch_skill only works on skills in
~/.config/goose/skills/ (where create_skill writes). This prevents
the agent from modifying user-curated or community-installed skills.
Signed-off-by: Michael Neale <michael.neale@gmail.com>
Two separate triggers for background review, matching Hermes:
- Memory review: fires after 5+ user turns (unchanged)
- Skill review: fires after 10+ tool iterations in a single reply
(complex work that required many tool calls = likely worth capturing)
When both trigger at once, sends a combined prompt that asks for both
memory AND skill extraction in one call (avoids double API cost).
Skill review prompt asks specifically: 'Was a non-trivial approach used
that required trial and error, or changing course, or did the user
expect a different method?' — focused on learnable struggle, not routine.
Review agent gets both memory + skill tools (create_skill, patch_skill,
load_skill) so it can create new skills or update existing ones.
Signed-off-by: Michael Neale <michael.neale@gmail.com>
Three compression improvements matching Hermes:
1. Lower compaction threshold from 0.8 to 0.5 — compress early, not as
an emergency. Creates headroom for knowledge management features.
2. Proactive tool result pruning — before calling the LLM summarizer,
replaces old tool results >200 chars with stub placeholders. Protects
the most recent 20 messages. This is free (no API cost) and dramatically
reduces what the summarizer has to process.
3. Structured compaction template — replaces freeform 'remove verbose parts'
prompt with Hermes-style structured sections: Goal, Constraints &
Preferences, Progress (Done/In Progress/Blocked), Key Decisions,
Relevant Files, Next Steps, Critical Context.
Signed-off-by: Michael Neale <michael.neale@gmail.com>
Two autonomous memory extraction mechanisms, matching Hermes:
Background review (knowledge_review.rs):
- Spawns after every 5+ turn reply as a background tokio task
- Takes conversation snapshot, finds memory tools via extension_manager
- Calls complete_fast() with review prompt asking for durable facts
- Mini agent loop: model calls memory tools, up to 8 calls
- Runs silently — user never sees it
Pre-compaction flush (wired into compact_messages):
- Before ANY compaction (auto, recovery, or manual), gives model one
cheap API call with only memory tools
- Prompt: 'session being compressed, save anything worth remembering'
- Catches all three compaction paths via single insertion point
- Falls back gracefully if flush fails
Also fixes clippy: UTF-8 safe string previews, removes unnecessary u32 cast.
Signed-off-by: Michael Neale <michael.neale@gmail.com>
Complete rewrite of the memory MCP server to match Hermes conventions:
- Single 'memory' tool with action param (add/replace/remove) + target (memory/user)
- § delimiter between entries (matches Hermes format)
- MEMORY.md for agent notes, USER.md for user profile
- Hard budget rejection: adds that exceed limit are REJECTED (not warned)
- Security scanning: blocks prompt injection patterns and invisible unicode
- Atomic file writes via tempfile + rename (no corruption on crash)
- Duplicate detection: rejects exact duplicate entries
- Frozen snapshot in system prompt with usage indicators
- 10 tests covering CRUD, budgets, security, and format
Signed-off-by: Michael Neale <michael.neale@gmail.com>
Reads ~/.config/goose/SOUL.md at prompt assembly time and prepends it
to the system prompt. This is a user-editable file (not agent-written)
that lets users customize the agent's personality, tone, and style.
Mirrors Hermes's ~/.hermes/SOUL.md concept. File is optional — if
missing or empty, the system prompt is unchanged. Content is sanitized
for malicious Unicode tags.
Signed-off-by: Michael Neale <michael.neale@gmail.com>
- Sanitize memory content: collapse consecutive newlines to prevent
\n\n delimiter corruption in remember and replace_memory
- create_skill: use OpenOptions::create_new for atomic existence check
(eliminates TOCTOU race)
- Wrap skill filesystem ops in spawn_blocking to avoid blocking Tokio
- Fix byte vs char inconsistency in ACP file read size check
- Rename GLOBAL_MEMORY_BUDGET to MEMORY_CATEGORY_BUDGET to clarify
per-category semantics
Signed-off-by: Michael Neale <michael.neale@gmail.com>
Tells the agent how to use memory and skills proactively:
- Save user corrections and preferences to user_profile
- Save environment facts to relevant categories
- Don't save task progress or temporary state
- Create skills after complex work, patch skills when found outdated
Signed-off-by: Michael Neale <michael.neale@gmail.com>
Skills can now be created from experience and patched when found outdated.
- create_skill: validates name, requires YAML frontmatter, writes to config dir
- patch_skill: find-and-replace in existing skills, rejects builtins and ambiguous matches
- Tests for creation, validation, patching, and error cases
Signed-off-by: Michael Neale <michael.neale@gmail.com>
- Add user_profile category with priority rendering in system prompt
- Add size budgets: 1375 chars for user_profile, 2200 chars for other memories
- Budget enforcement at render time (truncates with capacity warnings)
- Budget warnings at write time (warns agent when over budget)
- New replace_memory tool for atomic find-and-replace updates
- Updated instructions for proactive memory saving (no more 'ask before saving')
- Tests for user_profile rendering, budget enforcement, and replace logic
Signed-off-by: Michael Neale <michael.neale@gmail.com>
Add head+tail truncation (40% head, 60% tail) to automation_script
tool output. When stdout or stderr exceeds 50,000 characters, the
middle is replaced with a truncation notice preserving the beginning
and end of the output.
Signed-off-by: Michael Neale <michael.neale@gmail.com>
When a file read returns more than 200,000 characters (after applying
line limits from the ACP server), return a helpful message with the
character count, line count, and a preview of the first 50 lines,
instead of the full content. This prevents overwhelming the agent
context with very large files and guides the agent to use line/limit
parameters for targeted reads.
Signed-off-by: Michael Neale <michael.neale@gmail.com>
Change truncate_output to keep 20 lines from the head (40%) and 30
lines from the tail (60%) with a truncation notice in the middle,
instead of only keeping the last 50 lines. The notice shows how many
lines were dropped and where the full output was saved.
This gives better context when output is truncated, since the beginning
of command output often contains important information (e.g., the first
error in a build log).
Signed-off-by: Michael Neale <michael.neale@gmail.com>
Tool results between 100K-200K chars now get head+tail truncated in-place
(40% head, 60% tail) instead of passing through untouched. Results above
200K still get file-offloaded as before.
Signed-off-by: Michael Neale <michael.neale@gmail.com>