Skip to content

feat(plugin): session-recap injection — personalized onset greeting - #528

Draft
jeonghun-jj-lee wants to merge 4 commits into
mainfrom
523-featplugin-session-recap-injection-smart-onset-greeting-from-session-history
Draft

feat(plugin): session-recap injection — personalized onset greeting#528
jeonghun-jj-lee wants to merge 4 commits into
mainfrom
523-featplugin-session-recap-injection-smart-onset-greeting-from-session-history

Conversation

@jeonghun-jj-lee

Copy link
Copy Markdown
Contributor

Summary

Implements #523 — injects a ## Recent sessions (last 7 days) block into the system prompt so the onset router can personalize its greeting from actual session history, rather than depending on vault files only populated by dream-cycle workflows.

What changed

File Role
opencode-plugin/session_recap.ts Core module: DB read (bun:sqlite), filtering, caching, mechanical recap extraction, markdown composition
opencode-plugin/amicode_context.ts Hook wiring: now async, passes sessionID from input, calls buildRecentSessionsBlock
test/session_recap.test.ts 26 unit tests covering all pure logic paths

Design pivot from issue

The issue assumed client.sessions.list() via a PluginInput SDK handle — investigation showed the plugin receives no client. Pivoted to reading the SQLite DB directly via bun:sqlite (Bun built-in, zero deps). Same outcome, simpler surface.

Deferred

  • LLM summarization — the mechanical extract (first user prompt + numerical outcomes) is good enough for v1. LLM recaps need provider config the plugin doesn't have access to; will follow up once the small-model hook is wired.
  • Latency AC (< 3s for 5 sessions) — mechanical extraction is ~instant; the latency criterion is satisfied trivially without parallelism.

Test results

  • 26 new tests pass (filtering, outcome extraction, composition, caching, graceful degradation)
  • Full fast suite: 106/106 files, 1505/1505 tests pass
  • 2 pre-existing flaky E2E failures (binary server timeout) — unrelated

Closes #523

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3880444a-7e27-4c0a-af81-7b264da8c0b6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

…rom session history

Reads recent sessions (last 7 days) from the opencode SQLite DB via
bun:sqlite, extracts mechanical recaps (user prompts + numerical outcomes),
caches them to ~/.amico/session-recaps/, and injects a '## Recent sessions'
block into the system prompt. The onset router naturally uses this to
personalize the greeting without any changes to its own text.

Key decisions:
- bun:sqlite (Bun built-in) for DB reads — no npm deps, no SDK client needed
- Mechanical extraction (not LLM) for v1 — captures topic + fidelity/iteration
  numbers; LLM summarization deferred to a follow-up
- Env-seam pattern (AMICODE_SESSION_RECAP_CACHE_DIR, OPENCODE_DB) for testability
- Graceful degradation: returns null under Node/vitest or on any error
- Pure logic functions exported for unit testing (26 tests)

Acceptance criteria addressed:
- Returning user sees ## Recent sessions in system prompt
- Current session excluded; subagent sessions excluded
- Noise sessions (Compaction, <2 assistant msgs) filtered
- Cache prevents re-summarization
- Graceful degradation on failure (never crashes prompt build)

Closes #523
The onset router unconditionally offered pulse design as a top-level option,
causing the model to recommend pulses even for users whose intent is general
coding or product development. The design-a-pulse skill remains invocable by
name — it's just no longer the first thing offered on every session.

The remaining default options (resume active problem, resume campaign, fleet
ops, bring your own problem, just explore) are all state-gated: they only
appear when the relevant state exists, so the model builds the greeting from
what's actually there rather than defaulting to quantum control.
…ng skills

When onboarding is already complete, the overture score is not compiled into
the session's AGENTS.md. Previously, the onset router said 'skip to the
overture' for onboarding requests — but the overture wasn't there. The model
then improvised by invoking design-a-pulse from the skill index (the closest
thing to an interview it could find).

Now the router explicitly handles the post-completion case: tell the user
their profile exists and offer keep/redo. No skill invocation, no improvised
interview. The overture only runs when it's actually compiled in
(shouldOnboard = true at boot time).
…d for re-onboarding

Previously, the overture was only compiled into the session's AGENTS.md when
shouldOnboard=true at boot. Post-completion, it was absent — so 'begin
onboarding' required a window reload to recompile it in. Bad UX.

Now the overture is always compiled in (as a section after the general-purpose
copilot stub), gated by the onset router's instructions rather than by
presence/absence. The router says 'run the overture if present' — and it
always is. No reload needed to re-run onboarding.

Cost: ~12KB added to prompts that already had the stub. The overture content
is inert unless the user explicitly triggers it via the onset router.
@jeonghun-jj-lee
jeonghun-jj-lee force-pushed the 523-featplugin-session-recap-injection-smart-onset-greeting-from-session-history branch from aadb607 to c953b46 Compare August 23, 2026 17:33
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.

feat(plugin): session-recap injection — smart onset greeting from session history

1 participant