Skip to content

feat: add Goose conversation adapter and workspace agent option#230

Open
callmeradical wants to merge 1 commit intomarcus:mainfrom
callmeradical:support_for_goose
Open

feat: add Goose conversation adapter and workspace agent option#230
callmeradical wants to merge 1 commit intomarcus:mainfrom
callmeradical:support_for_goose

Conversation

@callmeradical
Copy link
Copy Markdown

Add Goose support across conversations and workspace flows.

Adapter implementation (internal/adapter/goose):

  • Implement full adapter contract: Detect, Sessions, SessionByID, Messages, Usage, Watch
  • Register adapter via register.go and wire startup import in cmd/sidecar/main.go
  • Parse Goose SQLite schema (sessions.db / messages.content_json) into Sidecar message model
  • Map structured content blocks (text, thinking/reasoning, toolRequest/toolResponse)
  • Link tool_result blocks back to tool_use entries by ToolUseID parity
  • Add MessageSearcher support via SearchMessages() using shared adapter search utilities
  • Add TargetedRefresher support via SessionByID() for O(1) targeted refresh
  • Add bounded message cache (LRU-style eviction, max 128) with signature-based invalidation
  • Return defensive message copies from cache to prevent mutation leaks
  • Strictly fail on malformed message content_json parse errors
  • Populate Session.FileSize for DB-backed sessions using sessions.db + sessions.db-wal size
  • Optimize Sessions query to use LEFT JOIN + GROUP BY counts instead of correlated per-row subquery
  • Implement WAL-aware watcher with debounce + non-blocking sends and best-effort SessionID enrichment

Workspace integration (internal/plugins/workspace):

  • Add new AgentType constant: goose
  • Add Goose display names/abbreviations, command mapping, and ordering in create/shell selectors
  • Keep skip-permissions unset for Goose (no known flag)
  • Extend agent command test coverage for Goose mapping

Tests and benchmarks:

  • Add comprehensive adapter unit tests (detect/sessions/messages/usage/watch/search/session lookup)
  • Add cache safety tests (defensive copy + invalidation on append)
  • Add malformed-content error-path test
  • Add benchmark suite for cache-hit messages and session listing (including 50-session benchmark)

Validation run:

  • go test ./internal/adapter/goose -run .
  • go test ./internal/adapter/goose -bench . -benchmem -run '^$'
  • go test ./internal/plugins/workspace -run '^TestGetAgentCommand$'
  • go build ./...

Add first-class Goose support across conversations and workspace flows.

Adapter implementation (internal/adapter/goose):
- Implement full adapter contract: Detect, Sessions, SessionByID, Messages, Usage, Watch
- Register adapter via register.go and wire startup import in cmd/sidecar/main.go
- Parse Goose SQLite schema (sessions.db / messages.content_json) into Sidecar message model
- Map structured content blocks (text, thinking/reasoning, toolRequest/toolResponse)
- Link tool_result blocks back to tool_use entries by ToolUseID parity
- Add MessageSearcher support via SearchMessages() using shared adapter search utilities
- Add TargetedRefresher support via SessionByID() for O(1) targeted refresh
- Add bounded message cache (LRU-style eviction, max 128) with signature-based invalidation
- Return defensive message copies from cache to prevent mutation leaks
- Strictly fail on malformed message content_json parse errors
- Populate Session.FileSize for DB-backed sessions using sessions.db + sessions.db-wal size
- Optimize Sessions query to use LEFT JOIN + GROUP BY counts instead of correlated per-row subquery
- Implement WAL-aware watcher with debounce + non-blocking sends and best-effort SessionID enrichment

Workspace integration (internal/plugins/workspace):
- Add new AgentType constant: goose
- Add Goose display names/abbreviations, command mapping, and ordering in create/shell selectors
- Keep skip-permissions unset for Goose (no known flag)
- Extend agent command test coverage for Goose mapping

Tests and benchmarks:
- Add comprehensive adapter unit tests (detect/sessions/messages/usage/watch/search/session lookup)
- Add cache safety tests (defensive copy + invalidation on append)
- Add malformed-content error-path test
- Add benchmark suite for cache-hit messages and session listing (including 50-session benchmark)

Validation run:
- go test ./internal/adapter/goose -run .
- go test ./internal/adapter/goose -bench . -benchmem -run '^$'
- go test ./internal/plugins/workspace -run '^TestGetAgentCommand$'
- go build ./...
@marcus
Copy link
Copy Markdown
Owner

marcus commented Mar 6, 2026

Hey @callmeradical! Starling here (AI assistant on the project). 👋

Wow — this is a seriously thorough Goose adapter implementation. The level of detail here is impressive:

  • Full adapter contract coverage (Detect, Sessions, SessionByID, Messages, Usage, Watch)
  • LRU message cache with signature-based invalidation and defensive copies
  • WAL-aware watcher with debounce
  • Optimized sessions query (JOIN instead of correlated subquery)
  • Comprehensive test + benchmark suite

2050+ lines of careful, well-structured work. Lars, thank you for investing this much into it.

Flagging Marcus to take a proper look — Goose is a popular agent and this rounds out the adapter roster nicely. Will get back to you with review notes. ✦

@callmeradical
Copy link
Copy Markdown
Author

Hey, just wanted to follow-up on this. Any chance of inclusion or any feedback for changes?

@marcus
Copy link
Copy Markdown
Owner

marcus commented Apr 18, 2026

Thanks for the follow up, looking now!

@marcus
Copy link
Copy Markdown
Owner

marcus commented Apr 18, 2026

Thanks for putting this together. I did a deep review and I don’t think we should merge this yet. Once the issues below are addressed, we’ll merge.

Main blockers:

  • Goose DB discovery is pointed at the wrong default paths for current Goose installs. The adapter is looking for .../goose/sessions.db, but current Goose docs place the SQLite DB under .../goose/sessions/sessions.db on Unix-like systems and %APPDATA%\\Block\\goose\\data\\sessions\\sessions.db on Windows. As written, the adapter will miss default installs.

  • The global watcher + targeted refresh path can leak sessions across projects. Sessions() filters by working_dir, but SessionByID() does not. Watch() backfills events with the latest changed session ID from the whole global DB, and the conversations plugin will then targeted-refresh and append that session if missing. That means activity in repo B can show up in repo A.

  • FileSize is being set to the total shared DB/WAL size for every Goose session. Sidecar uses FileSize for per-session large/huge warnings and auto-reload suppression, so one large Goose DB can incorrectly mark every Goose session as slow or huge.

  • The new workspace Goose CLI option likely isn’t actually usable for seeded starts. The launcher falls through to the generic “prompt as positional arg” path, but current Goose docs describe goose session and goose run -t/--interactive, not goose \"<prompt>\". There’s also no Goose-specific session-status detection in the workspace plugin.

Also, go test ./... is red on this branch in internal/plugins/workspace, while the full suite passes on local main, so the branch is not green yet.

What I verified:

  • go test ./internal/adapter/goose/... passes
  • go test ./internal/adapter/goose -bench . -benchmem passes
  • go test ./... fails on this PR branch

Once the pathing, watch/refresh isolation, FileSize handling, and workspace Goose integration are fixed, I’m comfortable merging.

@callmeradical
Copy link
Copy Markdown
Author

@marcus thanks for the look, will update and resubmit.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants