Commit Graph

4192 Commits

Author SHA1 Message Date
Michael Neale 54c52de540 fix snapshot: also exclude local skills for CI compatibility
Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-16 11:43:04 +10:00
Michael Neale f2cb6c8fef fix snapshot: regenerate without local memory data for CI compatibility
Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-16 11:26:44 +10:00
Michael Neale e382099d00 cargo fmt
Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-16 10:23:16 +10:00
Michael Neale 37b3afd50a update insta snapshots for prompt tuning changes
Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-16 10:06:04 +10:00
Michael Neale 735dc37705 knowledge review: use main model, always review memory, stronger prompts
- 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>
2026-04-16 10:02:30 +10:00
Michael Neale d13f56dbf4 prompt tuning 2026-04-16 07:59:07 +10:00
Michael Neale 55493ed5cb Merge remote-tracking branch 'origin/main' into micn/goose-memory-learning
* 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)
2026-04-15 10:54:18 +10:00
morgmart 529d6f7195 move agent skills to repo root for tool discoverability (#8535)
Signed-off-by: morgmart <98432065+morgmart@users.noreply.github.com>
2026-04-14 23:03:56 +00:00
tulsi 210ef52d81 port goose2 chat attachments into goose (#8534)
Signed-off-by: tulsi <tulsi@block.xyz>
2026-04-14 21:26:43 +00:00
github-actions[bot] 8e04d7c8be chore(release): bump version to 1.31.0 (minor) (#8527)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-14 14:48:16 +00:00
Alex Hancock 3fe750c01d feature: provider & model config (#8515) 2026-04-14 10:55:21 -04:00
Jack Amadeo 482f1962c1 Move goose2 (#8516)
Signed-off-by: Jack Amadeo <jackamadeo@squareup.com>
Co-authored-by: block-open-source[bot] <201011344+block-open-source[bot]@users.noreply.github.com>
Co-authored-by: block-open-source[bot] <1159699+block-open-source[bot]@users.noreply.github.com>
Co-authored-by: Wes <wesbillman@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Matt Toohey <contact@matttoohey.com>
Co-authored-by: tulsi <tulsi@block.xyz>
Co-authored-by: morgmart <98432065+morgmart@users.noreply.github.com>
Co-authored-by: Bradley Axen <baxen@squareup.com>
Co-authored-by: Alex Hancock <alexhancock@block.xyz>
Co-authored-by: Taylor Ho <taylorkmho@gmail.com>
Co-authored-by: Nahiyan Khan <nahiyan.khan@gmail.com>
Co-authored-by: Lifei Zhou <lifei@squareup.com>
2026-04-14 14:39:30 +00:00
Alex Hancock 17a404d4f9 feat: onboarding UX for the TUI (#8513) 2026-04-14 14:17:01 +00:00
Ido Savion 2f018285a4 Set MACOSX_DEPLOYMENT_TARGET=12.0 in build-cli.yml (#8525) 2026-04-14 13:40:30 +00:00
jh-block 65e5d97cac Improve local inference settings and model downloader (#8467)
Signed-off-by: jh-block <jhugo@block.xyz>
2026-04-14 08:50:50 +00:00
Michael Neale 9dcdd0d111 refactor: gate tool pruning on adaptive memory being active
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>
2026-04-14 15:44:21 +10:00
Michael Neale 8b46c13f9a fix: update snapshot for CI (remove local skills)
Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-14 15:38:29 +10:00
Michael Neale a33d8cd4f3 Move create_skill and patch_skill from skills to adaptive_memory extension
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>
2026-04-14 15:36:22 +10:00
Michael Neale b5a5837c54 refactor: reduce blast radius — opt-in adaptive memory, revert threshold, drop SOUL.md
- 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>
2026-04-14 15:14:42 +10:00
Michael Neale 92f36834ac fix: atomic memory locking + resetting review trigger (GPT-5.4 review)
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>
2026-04-14 14:44:52 +10:00
Michael Neale 82bd5f7b1b revert: restore large_response_handler to main — not in scope
Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-14 13:24:57 +10:00
Michael Neale 3956c001e6 fix: clippy constant assertions + snapshot without local skills
- 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>
2026-04-14 13:20:35 +10:00
Michael Neale 1963b34c6e revert: restore computercontroller to main — not in scope
Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-14 12:24:26 +10:00
Michael Neale 9248c05e73 revert: restore shell.rs to main — truncation changes not in scope
Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-14 12:22:07 +10:00
Michael Neale 3843e0268e test: knowledge_review tool filtering + skill test cleanup
- Extract filter_review_tools() for testability, add 10 unit tests:
  tool filtering (memory-only, skill-only, combined, excludes unrelated,
  empty scope), prompt selection logic, trigger thresholds, review limits

- Fix skill tests: use _test- prefixed names with TestSkillGuard (RAII
  cleanup) so tests don't leave artifacts in real config dir on panic

Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-14 12:09:12 +10:00
Michael Neale d59a511cef fix+test: critical bugs and comprehensive adaptive_memory tests
Fixes:
- UTF-8 safe truncation in build_session_context (was panicking on
  multibyte chars with String::truncate)
- char_count now uses .chars().count() not .len() (budget enforcement
  was counting bytes, not characters — wrong for non-ASCII)
- File locking via fs2: exclusive lock on writes, shared lock on reads
  in mutation paths. Prevents lost updates from concurrent background
  review + flush + foreground writes.

Tests (18 new):
- Security scanning: prompt injection, role hijack, exfiltration,
  invisible unicode, normal content allowed
- File format: § delimiter, read/write roundtrip, empty file, missing file
- Budget: char-not-byte counting, limit values, rejection when full
- Duplicate detection
- Filename/target mapping
- Render block: empty, user profile format, memory format, usage display
- Success text formatting

Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-14 11:57:12 +10:00
Michael Neale 53cbd97387 feat(knowledge_review): query past sessions for cross-session patterns
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>
2026-04-14 11:28:43 +10:00
Michael Neale 8cd03525b5 refactor(memory): move adaptive memory to platform extension, restore old MCP memory
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>
2026-04-14 11:13:22 +10:00
dorien-koelemeijer 2e529b7497 Add prompt injection mitigation logging back (#8518) 2026-04-14 00:44:49 +00:00
Michael Neale 79f2f6d209 fix(skills): patch_skill only modifies goose-managed skills
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>
2026-04-14 10:41:11 +10:00
Michael Neale 8f94e8438a feat(knowledge_review): add background skill review matching Hermes
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>
2026-04-14 09:57:57 +10:00
Michael Neale 29d54bc92b feat(context): lower threshold to 50%, proactive tool pruning, structured compaction template
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>
2026-04-14 09:17:40 +10:00
Michael Neale a9b6c7f6dd feat(agent): background memory review + pre-compaction flush
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>
2026-04-14 09:13:23 +10:00
Michael Neale 49d5acf796 feat(memory): rewrite to Hermes-compatible MEMORY.md + USER.md format
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>
2026-04-14 08:55:45 +10:00
Michael Neale 534ad46a76 feat(prompts): add SOUL.md persona file support
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>
2026-04-14 08:39:58 +10:00
Can H. Tartanoglu d2b473f8ee feat(providers): add llama-swap declarative provider (#8462) 2026-04-13 16:45:25 +00:00
Trang Le 4ad71920bc fix: Unable to Run goose update on Linux (#8465) 2026-04-13 15:55:59 +00:00
Michael Neale 28f385a1b2 revert: remove ACP file read cap — wrong layer for this
Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-13 18:25:15 +10:00
jh-block de317d5445 Add vision/image support for local inference models (#8442)
Signed-off-by: jh-block <jhugo@block.xyz>
2026-04-13 08:17:04 +00:00
Michael Neale 30bd92c9a0 fix: address review findings from GPT-5.4 second opinion
- 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>
2026-04-13 17:57:23 +10:00
Michael Neale ecab67a262 fix: update snapshots for system prompt change, fix UTF-8 safe truncation in computercontroller
Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-13 17:44:55 +10:00
Michael Neale 476796a780 style: cargo fmt
Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-13 17:41:14 +10:00
Michael Neale 3f6034c230 feat(prompts): add knowledge management guidance to system prompt
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>
2026-04-13 17:41:01 +10:00
Michael Neale 34789c3fae feat(skills): add create_skill and patch_skill tools
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>
2026-04-13 16:37:12 +10:00
Michael Neale 728f923e29 feat(memory): user_profile category, size budgets, replace_memory tool
- 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>
2026-04-13 16:33:59 +10:00
Michael Neale 56924c25ef feat(goose-mcp): cap automation_script stdout/stderr at 50k chars
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>
2026-04-13 16:29:57 +10:00
Michael Neale e7622848c0 feat(goose-acp): add file size cap to ACP file read tool
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>
2026-04-13 16:29:41 +10:00
Michael Neale 32a33871c5 feat(shell): change output truncation from tail-only to head+tail
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>
2026-04-13 16:29:28 +10:00
Michael Neale be1c171f70 feat(agent): add head+tail truncation tier to large_response_handler
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>
2026-04-13 16:26:57 +10:00
Michael Neale 8d73302021 feat(utils): add head+tail truncation for large text
Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-04-13 16:25:13 +10:00