mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 13:01:00 +00:00
Narrow the tool-mode Coach to the metric it was launched from
The tool-mode path dropped the launch scope's sources: the inventory probes the full source set, so a Coach opened from a metric page saw the whole inventory and could roam, while only the no-tools path honoured the narrowing. Inject a one-line FOCUS hint naming the launched domain(s) into the tool-mode user turn so the model prioritises that metric and fetches its figures first, with every other domain still reachable if the question leads there. Empty on a generic open, so the prompt prefix is unchanged on that path.
This commit is contained in:
1 parent
cf331dbef0
commit
d45d60627f
4 files changed
+73
-1
No files matched your search
@@ -78,6 +78,7 @@ import {
|
||||
COACH_TOOL_DEFS,
|
||||
buildCoachDataInventory,
|
||||
renderDataInventory,
|
||||
renderFocusHint,
|
||||
buildToolModeAddendum,
|
||||
runCoachToolLoop,
|
||||
MAX_ROUNDS,
|
||||
@@ -547,10 +548,17 @@ Reply now as the assistant, in ${locale === "de" ? "German" : "English"}.`;
|
||||
// that fire this turn share its reads.
|
||||
const inventory = await buildCoachDataInventory(userId, effectiveScope);
|
||||
const toolSystem = `${systemPrompt}\n\n${buildToolModeAddendum(locale)}`;
|
||||
// v1.21.0 (D1) — when the Coach was opened from a metric page/card, thread
|
||||
// the launch sources into a one-line FOCUS hint so tool mode honours the
|
||||
// metric the user is looking at (the no-tools path already narrows the
|
||||
// snapshot; the inventory probes the full set, so this is the tool-mode
|
||||
// equivalent of that narrowing). Empty string on a generic open.
|
||||
const focusHint = renderFocusHint(effectiveScope?.sources);
|
||||
const focusBlock = focusHint ? `${focusHint}\n\n` : "";
|
||||
const messages: AiMessage[] = [
|
||||
{
|
||||
role: "user",
|
||||
content: `${renderDataInventory(inventory)}${guidedBlock}
|
||||
content: `${focusBlock}${renderDataInventory(inventory)}${guidedBlock}
|
||||
|
||||
CONVERSATION
|
||||
${transcript}
|
||||
|
||||
Reference in new issue
Block a user