summaryrefslogtreecommitdiffhomepage
path: root/notes
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-24 04:02:09 +0900
committerAdam Malczewski <[email protected]>2026-06-24 04:02:09 +0900
commitb180cc1e03f90a139c90ef498d1c1fb449508fd7 (patch)
tree2daaf7bf051072bdf73b8857ea9daf30f77f3af7 /notes
parent69f89ab49be842d9826fb0b1621cc8c8dea5f14c (diff)
downloaddispatch-b180cc1e03f90a139c90ef498d1c1fb449508fd7.tar.gz
dispatch-b180cc1e03f90a139c90ef498d1c1fb449508fd7.zip
fix(system-prompt): reconstruct on cwd change via getWithMeta
The system-prompt service cached the resolved prompt on first turn and reused it on subsequent turns via get(). But the prompt is cwd-sensitive (file:AGENTS.md, prompt:cwd variables). When a conversation's cwd changed after the first turn, the cached prompt was stale — referenced files from the new cwd were not loaded. system-prompt: added getWithMeta(conversationId) returning { prompt, cwd } and stores resolved-cwd:<id> alongside resolved:<id> in construct(). session-orchestrator: subsequent turns now call getWithMeta, compare stored cwd vs effective cwd, and reconstruct if they differ. Compaction path (always constructs) and warm path (no system prompt) are unaffected. 1411 vitest pass; tsc + biome clean.
Diffstat (limited to 'notes')
-rw-r--r--notes/assumptions-log.md23
1 files changed, 22 insertions, 1 deletions
diff --git a/notes/assumptions-log.md b/notes/assumptions-log.md
index a04467b..57873e0 100644
--- a/notes/assumptions-log.md
+++ b/notes/assumptions-log.md
@@ -14,7 +14,28 @@
## Task 2 — System context builder not loading referenced files
-*Assumptions will be appended here as the work progresses.*
+1. **My reproduction shows the resolver is not buggy.** A standalone script using
+ the exact same `resolvePath(cwd, "AGENTS.md")` + `Bun.file(...).exists()/.text()`
+ logic successfully reads `/home/tradam/projects/dispatch/arch-rewrite/AGENTS.md`
+ when `cwd` is that directory. So the file-reading path in system-prompt works.
+2. **The failure mode is stale cached system prompt after a cwd change.** The system-
+ prompt service constructs once on the first turn of a new conversation and
+ reuses the result via `get()` on subsequent turns (cache-safe design). If the
+ conversation's cwd is changed after the first turn (or if the conversation was
+ created before system-prompt existed), the stored prompt was built against a
+ different cwd and does not include `AGENTS.md` from the new directory. I am
+ adding reconstruction when the stored prompt's cwd differs from the current
+ effective cwd.
+3. **Reconstructing on cwd change is the correct cache-vs-freshness trade.** The
+ system prompt is intentionally cwd-sensitive (`[prompt:cwd]` and `file:` vars);
+ when the cwd changes the prompt MUST change, so the cache was already stale
+ from a semantic standpoint. We still preserve construction-once-per-cwd.
+4. **Storage shape chosen:** keep `resolved:<conversationId>` as the resolved
+ prompt string (no migration needed for existing rows), and add a sibling key
+ `resolved-cwd:<conversationId>` for the cwd it was built against. A new
+ `SystemPromptService.getWithMeta(conversationId)` returns `{ prompt, cwd }`
+ so the orchestrator can compare before deciding to reconstruct.
+
## Task 3 — Persistent provider + model selection per chat