Persist brain-inline initial prompt (fixes empty chat + Log on automation sessions)#286
Persist brain-inline initial prompt (fixes empty chat + Log on automation sessions)#286ishaan-berri wants to merge 1 commit into
Conversation
Greptile SummaryBrain-inline sessions (used by automations) now run their
Confidence Score: 5/5Safe to merge. The brain-inline path now mirrors the well-tested finishBringUp path, the error-handling contract of runInitialPrompt is already self-contained, and the change touches exactly one code block in one file. The fix is a targeted one-block substitution that aligns an outlier code path with the pattern used everywhere else in the same file. runInitialPrompt already swallows its own errors (try/catch + best-effort DB write), so the absence of an explicit .catch() at the new call site is safe. The attachment-trigger widening is consistent with the identical condition already present in finishBringUp. No new async state, no new DB columns, no auth changes. No files require special attention.
|
| Filename | Overview |
|---|---|
| src/app/api/v1/managed_agents/agents/[agent_id]/session/route.ts | Brain-inline initial prompt now routes through runInitialPrompt instead of a bare harnessSendMessage, fixing missing persistence for automation sessions. Change is minimal and consistent with the existing finishBringUp path. |
Reviews (1): Last reviewed commit: "fix(sessions): persist brain-inline init..." | Re-trigger Greptile
Automation (and any brain-inline
claude-code-brain-inline) sessions showed nothing in the chat OR the Log once the live thread was gone.Root cause
Automations create sessions via the standard create-session route with
initial_prompt. The general path runs the prompt throughrunInitialPrompt, which persists the turn (appendUserMessage+completeAssistantMessage) and snapshots the thread toSession.history. But the brain-inline fast path fired a bareharnessSendMessageand persisted nothing — so the durable log +Session.historystayed empty, and both the chat (DB fallback) and the Log (reads DB) were blank after the live thread ended.Fix
Brain-inline now runs its initial prompt through the same
runInitialPromptpath as every other harness — so it records the turn and snapshots history. One file. (Also picks upinitial_attachmentshandling for free.)Testing — ran LAP locally (no k8s), brain-inline pointed at a local harness
Created a brain-inline session with an
initial_prompt, confirmed it persisted (durable_rows=2, history=2— was0/NULLbefore), then killed the harness (simulated reap) and reopened the session. Both panels render from the DB:Left = chat (user → thinking → haiku → DONE); right = Session Log (created → user → thinking → response, 6.6s · 295 tok). Harness was dead — served entirely from
Session.history.tsc+eslintclean.