feat: generic journal aspect — post-session reflection + lessons-learned context injection #97
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Journaling is currently planner-specific (hardcoded in
formulas/run-planner.tomlstep 3). The .profile issue chain (#86, #89) proposed journal writing and digestion as separate features. But journaling, digestion, and learning are one cross-cutting concern — every agent benefits from reflecting on what it learned, and the digestion should happen lazily before the next session, not via a separate agent.Proposed design
Three functions in
lib/formula-session.sh, opt-in by.profilerepo existence:1. Pre-session:
profile_load_lessonsHook point: During prompt construction, before the main session starts (in
dev-agent.sh,*-run.sh, etc.)What it does:
.profilerepo (Forgejo API:GET /repos/<login>/.profile). If not, return silently..profileto a cache dir (/home/agent/data/.profile/)journal/(excludearchive/). If >10 undigested entries:a. Run a
claude -pone-shot (same model as the agent, max_tokens 1000) with:knowledge/lessons-learned.md(if any)b. Write the response to
knowledge/lessons-learned.md(full rewrite)c. Move digested journals to
journal/archive/d. Commit and push to
.profilerepoknowledge/lessons-learned.md(hard cap at 2KB, truncate if larger) and setLESSONS_CONTEXTLESSONS_CONTEXTin the promptKey: Digestion is lazy — it only happens when the agent is about to run anyway, and only if enough journals have accumulated. No separate cron, no gardener, no coordinator. The phase handler does it in-line before handing off to the main session.
2. Post-session:
profile_write_journalHook point:
dev-agent.sh: after PR merge/block, beforeworktree_cleanuprun_formula_and_monitor(): after PHASE:done, beforeremove_formula_worktreeWhat it does:
.profilerepo. If not, return silently..profilecacheclaude -pone-shot (same model as the agent, max_tokens 500) with:.profile/journal/issue-<N>.md(append if exists).profilerepoImportant: This is a reflection prompt, not a log. The agent extracts lessons, not narrates actions.
3. Opt-in mechanism
The
.profilerepo existence is the flag. No config, no env var, no state file. Ifhire-an-agentwas run for this agent, it has a.profile. If not, both functions are silent no-ops.Lessons-learned constraints
knowledge/lessons-learned.mdmust be:Model
Both one-shot calls (journal + digestion) use the same model the agent is already running. The reflection should be done by the same mind that did the work. No model switching.
Relationship to existing issues
profile_load_lessons)profile_write_journalAffected files
lib/formula-session.sh— addprofile_load_lessons()andprofile_write_journal()dev/dev-agent.sh— call both functions at appropriate hook pointsplanner/planner-run.sh— callprofile_load_lessonsduring prompt setup,profile_write_journalpost-sessionformulas/run-planner.toml— simplify step 3, remove planner-specific journalingAcceptance criteria
profile_load_lessonschecks journal count and triggers digestion when >10claude -pone-shot before main session (same model, max_tokens 1000)knowledge/lessons-learned.md(full rewrite, not append)journal/archive/profile_load_lessonsinjects lessons into agent context when availableprofile_load_lessonsis a no-op when agent has no.profilerepoprofile_write_journalwrites a reflection entry after each session (same model, max_tokens 500)profile_write_journalis a no-op when agent has no.profilerepoDependencies
Depends on #84 (hire-an-agent — .profile repo must exist for dev-qwen).
Supersedes #86 (closed). Absorbs #89 (closed).