mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 21:32:18 +00:00
feat(coach): give every turn its memory and let the Coach remember and propose plans
What a person told the Coach never reached a tool-mode turn: facts and plans
rode the snapshot's memory block, which tool mode does not send, and the
extraction ran only past twenty turns and failed to parse on every
non-Codex chain, because the status chain runs in JSON-object mode while the
prompt asked for a bare array.
- Memory block: WHAT YOU KNOW ABOUT THIS PERSON, built per turn behind the
wire egress check (nothing is read on a refusal), fenced as data, at most
1,500 characters, never trimmed before the inventory. Confirmed facts
first, then the newest; active plans with a server-computed progress line;
reminders the person asked for. Medication facts stay out while the
medications module is off. Building it stamps last_used_at without moving
updated_at. buildCoachToolRequest and buildCoachProviderPrompts take it as
an optional memoryBlock; the snapshot memory keeps only the narrative and
trend recall.
- remember_fact: preferences, goals and context are saved at once
(source coach, source_message_id set); anything that names a condition,
limitation or medication, by category or by wording, is only proposed.
A fact must come from the person's current message; one note per answer.
- The person's answer reads the proposed fact from the encrypted trail on
the assistant message, never from the request.
- propose_plan writes a proposed plan; the tap activates it with its review
window counted from the tap. One per answer, three open at most.
- Progress: one sentence per active plan from the person's own day series
and units, also offered to the briefing (two lines at most, behind the
briefing capability). The plan review and the progress line read a step
plan as daily totals instead of per-sample means.
- Background extraction asks for {"facts":[]} / {"plans":[]} and reads
either shape, runs once a conversation has been quiet for 30 minutes, and
stores health facts as proposals offered once at the next turn.
- Unanswered plan and fact proposals lapse after 14 days in the reminder
sweep.
- Memory list API: POST saves one of the caller's own messages (the
remember button), PATCH edits a fact's wording, GET reports source, origin
and last use and never lists a waiting proposal.
- A structural guard keeps the egress check ahead of every read and the
callers of both builders to the turn and the briefing.
This commit is contained in:
1 parent
210becb28b
commit
acec87f02c
40 files changed
+5178
-678
No files matched your search
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* v1.41 — request schemas for the Coach memory list
|
||||
* (`/api/insights/coach/facts` + `/api/insights/coach/facts/[id]`).
|
||||
*
|
||||
* Lives outside the route files so the OpenAPI registry can import it without
|
||||
* touching the route modules. No `userId` field anywhere: the owner is always
|
||||
* narrowed from the session.
|
||||
*
|
||||
* - POST saves one of the person's own Coach messages as a fact (the remember
|
||||
* button). The body names the message, never the text: the server reads
|
||||
* the message it stored, so a client cannot write arbitrary memory through
|
||||
* this surface.
|
||||
* - PATCH edits a fact's wording. Only the text; the category and the source
|
||||
* stay as they are.
|
||||
*/
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { REMEMBER_FACT_MAX_CHARS } from "@/lib/ai/coach/memory/shared";
|
||||
|
||||
export const coachFactCreateSchema = z
|
||||
.object({
|
||||
messageId: z.string().min(1).max(64),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const coachFactPatchSchema = z
|
||||
.object({
|
||||
fact: z.string().trim().min(3).max(REMEMBER_FACT_MAX_CHARS),
|
||||
})
|
||||
.strict();
|
||||
Reference in new issue
Block a user