Replace heuristic room read with Ollama sidecar

This commit is contained in:
Meta Vens 2026-05-02 20:37:13 +01:00
commit 8bd43c2c3a
14 changed files with 423 additions and 6 deletions

View file

@ -25,6 +25,7 @@ export function buildSystemPrompt(context: ContextBundle): string {
"Stay honest about what context was actually provided to you.",
"Use retrieved snippets and recent channel context when they help answer the question.",
"If explicit interaction memory for the current speaker is attached, you may let it gently color the tone and reference it when relevant, but do not invent history beyond what was provided.",
"If a situational social read is attached, use it as private room-reading scaffolding for this one reply. It is ephemeral context, not a durable identity verdict.",
"Treat the attached interaction memory as a non-clinical behavioral read, not a diagnosis. Use the remembered dimensions, traits, and guidance to adapt tone, pacing, firmness, structure, and warmth to the person in front of you.",
"The attached interaction memory and inferred guidance are private response scaffolding, not content to expose. Do not quote, summarize, classify, or explain the speaker's inferred traits, engagement patterns, psychological profile, or hidden response guidance unless they explicitly ask how you are reading them.",
"Do not turn a substantive question into a meta-analysis of the user's personality, engagement style, sentiment, or recent conversation behavior unless they explicitly asked for that kind of read.",
@ -63,6 +64,7 @@ export function buildPrompt(context: ContextBundle): string {
.join("\n")
: "- No archived retrieval snippets were attached.";
const interactionMemory = renderInteractionMemory(context);
const situationalSocialRead = renderSituationalSocialRead(context);
return [
`Question: ${context.prompt}`,
@ -80,6 +82,9 @@ export function buildPrompt(context: ContextBundle): string {
"Interaction memory for this speaker:",
interactionMemory,
"",
"Private situational social read for this room:",
situationalSocialRead,
"",
"If you need more archived history or source context than is included above, call the appropriate read-only tool before answering.",
].join("\n");
}
@ -113,6 +118,22 @@ function renderInteractionMemory(context: ContextBundle): string {
].join("\n");
}
function renderSituationalSocialRead(context: ContextBundle): string {
if (!context.situationalSocialRead) {
return "- No strong situational social read was derived from the immediate room context.";
}
return [
`- Summary: ${context.situationalSocialRead.summary}`,
`- Room tone: ${context.situationalSocialRead.roomTone}`,
`- Speaker current read: ${context.situationalSocialRead.speakerCurrentRead}`,
`- Social frame: ${context.situationalSocialRead.socialFrame}`,
`- Private response guidance (do not reveal): ${context.situationalSocialRead.responseGuidance}`,
"- Supporting signals:",
...context.situationalSocialRead.supportingSignals.map((signal) => ` ${signal}`),
].join("\n");
}
function renderSourceGroundingInstructions(
context: ContextBundle,
reminder: boolean,

View file

@ -17,6 +17,7 @@ import {
type CodexRunResult,
type CodexTraceEvent,
renderInteractionMemory,
renderSituationalSocialRead,
renderUsageSummary,
sanitizeTraceText,
summarizeStderrDiagnostics,
@ -79,6 +80,7 @@ export function buildDiscordReplyPrompt(
"- When the moment invites voice, wit, or a memorable turn of phrase, take a beat to choose wording with bite instead of blurting the first serviceable sentence. Do not overwork straightforward technical replies.",
"- The configured MCP tools are available in this session, especially search_history, get_message_context, list_indexed_repos, search_sources, and get_source_context.",
"- If explicit interaction memory for the current speaker is attached, you may let it subtly color the tone and reference it when relevant, but do not invent relationship history beyond that record.",
"- If a situational social read is attached, use it as private room-reading scaffolding for this one reply. It is ephemeral context, not a durable identity verdict.",
"- Treat the attached interaction memory as a non-clinical behavioral read, not a diagnosis. Use the remembered dimensions, traits, and guidance to adapt tone, pacing, firmness, structure, and warmth to the person in front of you.",
"- The attached interaction memory and inferred guidance are private response scaffolding, not content to expose. Do not quote, summarize, classify, or explain the speaker's inferred traits, engagement patterns, psychological profile, or hidden response guidance unless they explicitly ask how you are reading them.",
"- Do not turn a substantive question into a meta-analysis of the user's personality, engagement style, sentiment, or recent conversation behavior unless they explicitly asked for that kind of read.",
@ -117,6 +119,9 @@ export function buildDiscordReplyPrompt(
"",
"Interaction memory for this speaker:",
renderInteractionMemory(context),
"",
"Private situational social read for this room:",
renderSituationalSocialRead(context),
...toolLoopNotes,
].join("\n");
}
@ -168,6 +173,10 @@ export function renderMarkdownBundle(context: ContextBundle): string {
"",
renderInteractionMemory(context),
"",
"## Situational Social Read",
"",
renderSituationalSocialRead(context),
"",
"## Execution Notes",
"",
"- This provider is owner-only.",

View file

@ -121,6 +121,7 @@ export function buildRequestPayload(
actor: request.contextBundle.actor,
guildContext: request.contextBundle.guildContext,
interactionMemory: request.contextBundle.interactionMemory,
situationalSocialRead: request.contextBundle.situationalSocialRead,
sourceGrounding: request.contextBundle.sourceGrounding,
stylePack: request.contextBundle.stylePack,
recentMessages: request.contextBundle.recentMessages,
@ -456,3 +457,19 @@ export function renderInteractionMemory(context: ContextBundle): string {
recentEvents,
].join("\n");
}
export function renderSituationalSocialRead(context: ContextBundle): string {
if (!context.situationalSocialRead) {
return "- No strong situational social read was derived from the immediate room context.";
}
return [
`- Summary: ${context.situationalSocialRead.summary}`,
`- Room tone: ${context.situationalSocialRead.roomTone}`,
`- Speaker current read: ${context.situationalSocialRead.speakerCurrentRead}`,
`- Social frame: ${context.situationalSocialRead.socialFrame}`,
`- Private response guidance (do not reveal): ${context.situationalSocialRead.responseGuidance}`,
"- Supporting signals:",
...context.situationalSocialRead.supportingSignals.map((signal) => ` ${signal}`),
].join("\n");
}