From 3de9dc46b6d00fe6f743c4f85c3185c7b7841f38 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 2 May 2026 22:57:04 +0100 Subject: [PATCH] Broaden room reads into transcript profiling --- apps/bot/src/discord-bot-handlers.ts | 13 + apps/bot/src/discord-bot-support.ts | 65 +++ packages/core/src/interaction-memory-logic.ts | 1 + .../core/src/interaction-memory-profile.ts | 359 ++++++++++++++- packages/core/src/interaction-memory.ts | 58 ++- packages/core/src/situational-social-read.ts | 415 ++++++++++++++---- packages/core/src/social-read-glossary.ts | 373 ++++++++++++++++ .../src/state-storage-postgres-bootstrap.ts | 3 +- ...ate-storage-postgres-interaction-memory.ts | 30 +- packages/providers/src/local-llm-render.ts | 26 ++ packages/providers/src/owner-codex-shared.ts | 26 ++ packages/shared/src/index.ts | 150 +++++++ state/evidence.jsonl | 1 + 13 files changed, 1424 insertions(+), 96 deletions(-) create mode 100644 packages/core/src/social-read-glossary.ts diff --git a/apps/bot/src/discord-bot-handlers.ts b/apps/bot/src/discord-bot-handlers.ts index 090e6c8..71aa99e 100644 --- a/apps/bot/src/discord-bot-handlers.ts +++ b/apps/bot/src/discord-bot-handlers.ts @@ -217,6 +217,19 @@ export async function handlePrompt(options: PromptHandlerOptions): Promise recentMessages, interactionMemory, }); + const socialReadObservedAt = new Date().toISOString(); + const socialReadEvidence = (situationalSocialRead?.participantReads ?? []).map( + ({ situationalState: _situationalState, ...entry }) => ({ + ...entry, + observedAt: socialReadObservedAt, + }), + ); + + if (socialReadEvidence.length > 0) { + await options.interactionMemory.recordSocialReadEvidence(socialReadEvidence); + interactionMemory = await options.interactionMemory.getProfile(options.actor.id); + } + const pronounEvidence = situationalSocialRead?.pronounEvidence ?? []; const rememberedInteraction = await options.interactionMemory.recordInteraction({ actorId: options.actor.id, diff --git a/apps/bot/src/discord-bot-support.ts b/apps/bot/src/discord-bot-support.ts index 0ec4270..f0ce888 100644 --- a/apps/bot/src/discord-bot-support.ts +++ b/apps/bot/src/discord-bot-support.ts @@ -479,6 +479,39 @@ export function renderInteractionProfileDisclosure( ) .join("\n") : "- No stored pronoun evidence yet."; + const socialReadEvidence = + profile.socialReadEvidence.length > 0 + ? profile.socialReadEvidence + .slice(0, 8) + .map( + (entry) => + `- [${entry.observedAt}] ${entry.summary} Signals: ${entry.supportingSignals.slice(0, 3).join(" | ") || "none recorded"}`, + ) + .join("\n") + : "- No transcript-derived participant reads are stored yet."; + const scoreSections = [ + formatScoredProfileLabelSection( + "Underlying organization", + profile.underlyingOrganizationScores, + ), + formatScoredProfileLabelSection( + "Stable dispositions", + profile.stableDispositionScores, + ), + formatScoredProfileLabelSection( + "Behavioral dimensions", + profile.behavioralDimensionScores, + ), + formatScoredProfileLabelSection( + "Presentation strategies", + profile.presentationStrategyScores, + ), + formatScoredProfileLabelSection("Voice style", profile.voiceStyleScores), + ].join("\n\n"); + const currentSpeakerRead = + situationalSocialRead?.participantReads.find( + (entry) => entry.actorId === profile.actorId, + ) ?? situationalSocialRead?.participantReads[0]; const situationalSection = situationalSocialRead ? [ "", @@ -488,6 +521,16 @@ export function renderInteractionProfileDisclosure( `- Speaker read: ${situationalSocialRead.speakerCurrentRead}`, `- Social frame: ${situationalSocialRead.socialFrame}`, `- Response guidance: ${situationalSocialRead.responseGuidance}`, + currentSpeakerRead + ? `- Current speaker situational state: ${currentSpeakerRead.situationalState.length > 0 ? currentSpeakerRead.situationalState.join(", ") : "none detected"}` + : "- Current speaker situational state: none detected", + currentSpeakerRead + ? `- Current speaker visible labels: behavioral=${ + currentSpeakerRead.behavioralDimensions.join(", ") || "none" + }; presentation=${ + currentSpeakerRead.presentationStrategies.join(", ") || "none" + }; voice=${currentSpeakerRead.voiceStyle.join(", ") || "none"}` + : "- Current speaker visible labels: none detected", ].join("\n") : ""; @@ -506,6 +549,9 @@ export function renderInteractionProfileDisclosure( "Interaction dimensions:", dimensions, "", + "Transcript-derived profile scores:", + scoreSections, + "", "Pronoun handling:", `- Policy: ${profile.pronounPolicy}`, `- Resolved sets: ${profile.resolvedPronounSets.length > 0 ? profile.resolvedPronounSets.join(", ") : profile.resolvedPronounSet ?? "none"}`, @@ -518,12 +564,31 @@ export function renderInteractionProfileDisclosure( "", "Recent remembered incidents:", recentEvents, + "", + "Stored transcript-derived reads:", + socialReadEvidence, situationalSection, ] .filter((section) => section.length > 0) .join("\n"); } +function formatScoredProfileLabelSection( + title: string, + labels: Array<{ label: string; score: number; summary: string }>, +): string { + if (labels.length === 0) { + return `${title}:\n- No strong signal yet.`; + } + + return [ + `${title}:`, + ...labels + .slice(0, 8) + .map((entry) => `- ${entry.label} (${entry.score}): ${entry.summary}`), + ].join("\n"); +} + export function truncate(input: string, limit: number): string { if (input.length <= limit) { return input; diff --git a/packages/core/src/interaction-memory-logic.ts b/packages/core/src/interaction-memory-logic.ts index bf103fc..65eeafc 100644 --- a/packages/core/src/interaction-memory-logic.ts +++ b/packages/core/src/interaction-memory-logic.ts @@ -11,6 +11,7 @@ export { emptyInteractionProfile, emptyInteractionIdentityState, mergePronounEvidenceIntoIdentityState, + mergeSocialReadEvidenceIntoIdentityState, normalizeInteractionIdentityState, summarizeInteractionProfile, } from "./interaction-memory-profile"; diff --git a/packages/core/src/interaction-memory-profile.ts b/packages/core/src/interaction-memory-profile.ts index 00fe509..80be39b 100644 --- a/packages/core/src/interaction-memory-profile.ts +++ b/packages/core/src/interaction-memory-profile.ts @@ -6,6 +6,8 @@ import { type PronounEvidence, type PronounPolicy, type PronounSet, + type ScoredProfileLabel, + type StoredTranscriptParticipantRead, } from "@voidbot/shared"; import { @@ -18,6 +20,13 @@ import { SUMMARY_EVENT_LIMIT, SUMMARY_NOTABLE_TAGS, } from "./interaction-memory-shared"; +import { + BEHAVIORAL_DIMENSION_DESCRIPTORS, + PRESENTATION_STRATEGY_DESCRIPTORS, + STABLE_DISPOSITION_DESCRIPTORS, + UNDERLYING_ORGANIZATION_DESCRIPTORS, + VOICE_STYLE_DESCRIPTORS, +} from "./social-read-glossary"; interface PsychologicalRead { psychologicalProfile: string; @@ -26,6 +35,14 @@ interface PsychologicalRead { responseGuidance: string; } +interface SocialReadProfileScores { + underlyingOrganizationScores: ScoredProfileLabel[]; + stableDispositionScores: ScoredProfileLabel[]; + behavioralDimensionScores: ScoredProfileLabel[]; + presentationStrategyScores: ScoredProfileLabel[]; + voiceStyleScores: ScoredProfileLabel[]; +} + export interface InteractionIdentityState { pronounPolicy: PronounPolicy; resolvedPronounSet?: PronounSet; @@ -33,9 +50,11 @@ export interface InteractionIdentityState { pronounConfidence?: number; pronounGuidance: string; pronounEvidence: PronounEvidence[]; + socialReadEvidence: StoredTranscriptParticipantRead[]; } const MAX_PRONOUN_EVIDENCE = 12; +const MAX_SOCIAL_READ_EVIDENCE = 12; export function summarizeInteractionProfile( actorId: string, @@ -62,8 +81,14 @@ export function summarizeInteractionProfile( -MAX_AFFINITY_SCORE, MAX_AFFINITY_SCORE, ); - const psychologicalRead = buildPsychologicalRead(normalizedEvents); const normalizedIdentityState = normalizeInteractionIdentityState(identityState); + const socialReadScores = buildSocialReadProfileScores( + normalizedIdentityState.socialReadEvidence, + ); + const psychologicalRead = buildPsychologicalRead( + normalizedEvents, + socialReadScores.behavioralDimensionScores, + ); const profile: InteractionMemoryProfile = { actorId, @@ -84,6 +109,11 @@ export function summarizeInteractionProfile( psychologicalProfile: psychologicalRead.psychologicalProfile, inferredTraits: psychologicalRead.inferredTraits, interactionDimensions: psychologicalRead.interactionDimensions, + underlyingOrganizationScores: socialReadScores.underlyingOrganizationScores, + stableDispositionScores: socialReadScores.stableDispositionScores, + behavioralDimensionScores: socialReadScores.behavioralDimensionScores, + presentationStrategyScores: socialReadScores.presentationStrategyScores, + voiceStyleScores: socialReadScores.voiceStyleScores, responseGuidance: psychologicalRead.responseGuidance, pronounPolicy: normalizedIdentityState.pronounPolicy, resolvedPronounSet: normalizedIdentityState.resolvedPronounSet, @@ -91,7 +121,10 @@ export function summarizeInteractionProfile( pronounConfidence: normalizedIdentityState.pronounConfidence, pronounGuidance: normalizedIdentityState.pronounGuidance, pronounEvidence: normalizedIdentityState.pronounEvidence, - lastInteractionAt: normalizedEvents[normalizedEvents.length - 1]?.timestamp, + socialReadEvidence: normalizedIdentityState.socialReadEvidence, + lastInteractionAt: + normalizedEvents[normalizedEvents.length - 1]?.timestamp ?? + normalizedIdentityState.socialReadEvidence[0]?.observedAt, recentEvents, }; @@ -114,6 +147,7 @@ export function emptyInteractionIdentityState(): InteractionIdentityState { pronounGuidance: "No reliable pronoun preference is established for this speaker yet. Use their name or neutral phrasing unless the current context states otherwise.", pronounEvidence: [], + socialReadEvidence: [], }; } @@ -124,7 +158,11 @@ export function normalizeInteractionIdentityState( return emptyInteractionIdentityState(); } - return resolveInteractionIdentityState(state.pronounEvidence ?? []); + const resolved = resolveInteractionIdentityState(state.pronounEvidence ?? []); + return { + ...resolved, + socialReadEvidence: dedupeSocialReadEvidence(state.socialReadEvidence ?? []), + }; } export function mergePronounEvidenceIntoIdentityState( @@ -135,12 +173,65 @@ export function mergePronounEvidenceIntoIdentityState( ...(existingState?.pronounEvidence ?? []), ...newEvidence, ]); - return resolveInteractionIdentityState(mergedEvidence); + const resolved = resolveInteractionIdentityState(mergedEvidence); + return { + ...resolved, + socialReadEvidence: dedupeSocialReadEvidence(existingState?.socialReadEvidence ?? []), + }; +} + +export function mergeSocialReadEvidenceIntoIdentityState( + existingState: Partial | undefined, + newEvidence: StoredTranscriptParticipantRead[], +): InteractionIdentityState { + const normalizedExisting = normalizeInteractionIdentityState(existingState); + return { + ...normalizedExisting, + socialReadEvidence: dedupeSocialReadEvidence([ + ...normalizedExisting.socialReadEvidence, + ...newEvidence, + ]), + }; } function determineDisposition( profile: InteractionMemoryProfile, ): InteractionMemoryDisposition { + if (profile.totalInteractions === 0 && profile.socialReadEvidence.length > 0) { + const warmthScore = readProfileLabelScore( + profile.behavioralDimensionScores, + "interpersonal_warmth", + ); + const hostilityScore = readProfileLabelScore( + profile.behavioralDimensionScores, + "hostility", + ); + const suspicionScore = readProfileLabelScore( + profile.behavioralDimensionScores, + "suspicion", + ); + const distanceScore = readProfileLabelScore( + profile.behavioralDimensionScores, + "distance_seeking", + ); + + if (hostilityScore >= 2) { + return "hostile"; + } + + if (suspicionScore >= 2 || distanceScore >= 2) { + return "wary"; + } + + if (warmthScore >= 4) { + return "warm"; + } + + if (warmthScore >= 2) { + return "friendly"; + } + } + if (profile.totalInteractions === 0) { return "neutral"; } @@ -174,7 +265,14 @@ function determineDisposition( function buildProfileSummary(profile: InteractionMemoryProfile): string { const leading = describeDisposition(profile.disposition); - const counts = `${profile.totalInteractions} remembered interaction${profile.totalInteractions === 1 ? "" : "s"}: ${profile.directInteractionCount} direct, ${profile.ambientMentionCount} ambient, ${profile.positiveCount} positive, ${profile.neutralCount} neutral, ${profile.negativeCount} negative.`; + const counts = [ + `${profile.totalInteractions} remembered interaction${profile.totalInteractions === 1 ? "" : "s"}: ${profile.directInteractionCount} direct, ${profile.ambientMentionCount} ambient, ${profile.positiveCount} positive, ${profile.neutralCount} neutral, ${profile.negativeCount} negative.`, + profile.socialReadEvidence.length > 0 + ? `${profile.socialReadEvidence.length} transcript-derived room read${profile.socialReadEvidence.length === 1 ? "" : "s"} are also shaping this profile.` + : undefined, + ] + .filter((entry): entry is string => Boolean(entry)) + .join(" "); const recentNotable = profile.recentEvents .slice() .reverse() @@ -192,6 +290,74 @@ function buildProfileSummary(profile: InteractionMemoryProfile): string { : `${leading} ${counts} ${psych}`; } +function buildSocialReadProfileScores( + evidence: StoredTranscriptParticipantRead[], +): SocialReadProfileScores { + return { + underlyingOrganizationScores: buildScoredLabelsFromEvidence( + evidence, + (entry) => entry.underlyingOrganization, + UNDERLYING_ORGANIZATION_DESCRIPTORS, + ), + stableDispositionScores: buildScoredLabelsFromEvidence( + evidence, + (entry) => entry.stableDispositions, + STABLE_DISPOSITION_DESCRIPTORS, + ), + behavioralDimensionScores: buildScoredLabelsFromEvidence( + evidence, + (entry) => entry.behavioralDimensions, + BEHAVIORAL_DIMENSION_DESCRIPTORS, + ), + presentationStrategyScores: buildScoredLabelsFromEvidence( + evidence, + (entry) => entry.presentationStrategies, + PRESENTATION_STRATEGY_DESCRIPTORS, + ), + voiceStyleScores: buildScoredLabelsFromEvidence( + evidence, + (entry) => entry.voiceStyle, + VOICE_STYLE_DESCRIPTORS, + ), + }; +} + +function buildScoredLabelsFromEvidence( + evidence: StoredTranscriptParticipantRead[], + selector: (entry: StoredTranscriptParticipantRead) => readonly T[], + descriptors: Record, +): ScoredProfileLabel[] { + const counts = new Map(); + + for (const entry of evidence) { + for (const key of selector(entry)) { + counts.set(key, (counts.get(key) ?? 0) + 1); + } + } + + return [...counts.entries()] + .map(([key, score]) => ({ + key, + label: descriptors[key].label, + score, + summary: `Observed in ${score} transcript-derived room read${score === 1 ? "" : "s"}. ${descriptors[key].description}`, + })) + .sort((left, right) => { + if (right.score !== left.score) { + return right.score - left.score; + } + + return left.label.localeCompare(right.label); + }); +} + +function readProfileLabelScore( + labels: ScoredProfileLabel[], + key: string, +): number { + return labels.find((entry) => entry.key === key)?.score ?? 0; +} + function describeDisposition(disposition: InteractionMemoryDisposition): string { switch (disposition) { case "warm": @@ -209,8 +375,11 @@ function describeDisposition(disposition: InteractionMemoryDisposition): string } } -function buildPsychologicalRead(events: InteractionMemoryEvent[]): PsychologicalRead { - if (events.length === 0) { +function buildPsychologicalRead( + events: InteractionMemoryEvent[], + behavioralDimensionScores: ScoredProfileLabel[], +): PsychologicalRead { + if (events.length === 0 && behavioralDimensionScores.length === 0) { return { psychologicalProfile: "Current psychological read: nothing solid yet; there is not enough remembered signal to infer a stable vibe.", @@ -239,7 +408,8 @@ function buildPsychologicalRead(events: InteractionMemoryEvent[]): Psychological const rigidityCount = readTagCount(tagCounts, "rigidity"); const withdrawalCount = readTagCount(tagCounts, "withdrawal"); const boundaryCount = readTagCount(tagCounts, "boundary"); - const interactionDimensions = collectInteractionDimensions([ + const interactionDimensions = mergeInteractionDimensions( + collectInteractionDimensions([ { key: "warmth", label: "Warmth", @@ -346,7 +516,9 @@ function buildPsychologicalRead(events: InteractionMemoryEvent[]): Psychological "Shows some detachment or withdrawal.", ], }, - ]); + ]), + buildSocialReadDimensions(behavioralDimensionScores), + ); const inferredTraits: string[] = []; const warmthDimension = findDimensionScore(interactionDimensions, "warmth"); const driveDimension = findDimensionScore(interactionDimensions, "drive"); @@ -358,6 +530,9 @@ function buildPsychologicalRead(events: InteractionMemoryEvent[]): Psychological const suspicionDimension = findDimensionScore(interactionDimensions, "suspicion"); const rigidityDimension = findDimensionScore(interactionDimensions, "rigidity"); const withdrawalDimension = findDimensionScore(interactionDimensions, "withdrawal"); + const volatilityDimension = findDimensionScore(interactionDimensions, "volatility"); + const attachmentDimension = findDimensionScore(interactionDimensions, "attachment"); + const distanceDimension = findDimensionScore(interactionDimensions, "distance"); pushTraitFromDimension(interactionDimensions, inferredTraits, "warmth", 2, "appreciative"); pushTraitFromDimension(interactionDimensions, inferredTraits, "drive", 2, "ambitious"); @@ -370,6 +545,9 @@ function buildPsychologicalRead(events: InteractionMemoryEvent[]): Psychological pushTraitFromDimension(interactionDimensions, inferredTraits, "suspicion", 2, "suspicious"); pushTraitFromDimension(interactionDimensions, inferredTraits, "rigidity", 2, "rigid"); pushTraitFromDimension(interactionDimensions, inferredTraits, "withdrawal", 2, "withdrawn"); + pushTraitFromDimension(interactionDimensions, inferredTraits, "volatility", 2, "volatile"); + pushTraitFromDimension(interactionDimensions, inferredTraits, "attachment", 2, "attachment-seeking"); + pushTraitFromDimension(interactionDimensions, inferredTraits, "distance", 2, "avoidant"); ensureTrait(inferredTraits, driveDimension >= 2, "ambitious"); ensureTrait(inferredTraits, driveDimension >= 2, "motivated"); ensureTrait(inferredTraits, validationDimension >= 2, "insecure"); @@ -380,6 +558,9 @@ function buildPsychologicalRead(events: InteractionMemoryEvent[]): Psychological ensureTrait(inferredTraits, suspicionDimension >= 2, "suspicious"); ensureTrait(inferredTraits, rigidityDimension >= 2, "rigid"); ensureTrait(inferredTraits, withdrawalDimension >= 2, "withdrawn"); + ensureTrait(inferredTraits, volatilityDimension >= 2, "volatile"); + ensureTrait(inferredTraits, attachmentDimension >= 2, "attachment-seeking"); + ensureTrait(inferredTraits, distanceDimension >= 2, "avoidant"); ensureTrait(inferredTraits, grandiosityDimension >= 3, "grandiose"); const traitList = inferredTraits.length > 0 ? inferredTraits.join(", ") : "hard to read"; @@ -400,6 +581,15 @@ function buildPsychologicalRead(events: InteractionMemoryEvent[]): Psychological } else if (rigidityDimension >= 2 && anxietyDimension >= 2) { psychologicalProfile = "Current psychological read: tense and rigid, likely to cling to precision or control when they feel uncertain."; + } else if (attachmentDimension >= 2 && anxietyDimension >= 2) { + psychologicalProfile = + "Current psychological read: anxious and attachment-seeking, likely to reach for reassurance, closeness, or being specifically chosen."; + } else if (distanceDimension >= 2 && withdrawalDimension >= 2) { + psychologicalProfile = + "Current psychological read: distance-seeking and avoidant, inclined to keep emotional space and resent being crowded."; + } else if (volatilityDimension >= 2) { + psychologicalProfile = + "Current psychological read: emotionally volatile, with quicker swings or escalations than the room around them."; } else if (withdrawalDimension >= 2) { psychologicalProfile = "Current psychological read: detached or avoidant, not especially interested in a warm back-and-forth."; @@ -445,6 +635,24 @@ function buildPsychologicalRead(events: InteractionMemoryEvent[]): Psychological ); } + if (distanceDimension >= 2) { + guidance.push( + "Do not crowd them, overclaim intimacy, or demand disclosure. Give them room to stay opaque without treating that as a personal insult.", + ); + } + + if (attachmentDimension >= 2) { + guidance.push( + "Be warm without making false promises of privileged closeness. Reassure carefully, then keep the relationship grounded and bounded.", + ); + } + + if (volatilityDimension >= 2) { + guidance.push( + "Keep your own tone steady and do not mirror sudden swings back at them. Calm structure beats emotional whiplash.", + ); + } + if (controlDimension >= 2) { guidance.push( "If they keep pressing the same point or ignore a prior answer, push back, set boundaries, and refuse if needed.", @@ -584,6 +792,111 @@ function clamp(value: number, min: number, max: number): number { return Math.min(max, Math.max(min, value)); } +function buildSocialReadDimensions( + behavioralDimensionScores: ScoredProfileLabel[], +): InteractionMemoryDimension[] { + if (behavioralDimensionScores.length === 0) { + return []; + } + + return behavioralDimensionScores + .map((scoreLabel) => { + const config = mapBehavioralDimensionKey(scoreLabel.key); + + if (!config) { + return undefined; + } + + const score = transcriptCountToDimensionScore(scoreLabel.score); + + if (score === 0) { + return undefined; + } + + const descriptor = + BEHAVIORAL_DIMENSION_DESCRIPTORS[ + scoreLabel.key as keyof typeof BEHAVIORAL_DIMENSION_DESCRIPTORS + ]; + + return { + key: config.key, + label: config.label, + score, + summary: `Observed in ${scoreLabel.score} transcript-derived room read${scoreLabel.score === 1 ? "" : "s"}. ${descriptor.description}`, + } satisfies InteractionMemoryDimension; + }) + .filter((entry): entry is InteractionMemoryDimension => Boolean(entry)) + .filter((entry) => entry.score > 0); +} + +function mergeInteractionDimensions( + left: InteractionMemoryDimension[], + right: InteractionMemoryDimension[], +): InteractionMemoryDimension[] { + const merged = new Map(); + + for (const dimension of [...left, ...right]) { + const existing = merged.get(dimension.key); + + if (!existing || dimension.score > existing.score) { + merged.set(dimension.key, dimension); + } + } + + return [...merged.values()]; +} + +function transcriptCountToDimensionScore(value: number): number { + if (value >= 4) { + return 3; + } + + if (value >= 2) { + return 2; + } + + if (value >= 1) { + return 1; + } + + return 0; +} + +function mapBehavioralDimensionKey( + key: ScoredProfileLabel["key"], +): { key: string; label: string } | undefined { + switch (key) { + case "interpersonal_warmth": + return { key: "warmth", label: "Warmth" }; + case "drive": + return { key: "drive", label: "Drive" }; + case "grandiosity": + return { key: "grandiosity", label: "Grandiosity" }; + case "validation_seeking": + return { key: "validation", label: "Validation-Seeking" }; + case "anxiety": + return { key: "anxiety", label: "Anxiety" }; + case "control_pressure": + return { key: "control", label: "Control Pressure" }; + case "hostility": + return { key: "hostility", label: "Hostility" }; + case "suspicion": + return { key: "suspicion", label: "Suspicion" }; + case "rigidity": + return { key: "rigidity", label: "Rigidity" }; + case "withdrawal": + return { key: "withdrawal", label: "Withdrawal" }; + case "volatility": + return { key: "volatility", label: "Volatility" }; + case "attachment_seeking": + return { key: "attachment", label: "Attachment-Seeking" }; + case "distance_seeking": + return { key: "distance", label: "Distance-Seeking" }; + default: + return undefined; + } +} + function resolveInteractionIdentityState( evidence: PronounEvidence[], ): InteractionIdentityState { @@ -629,6 +942,7 @@ function resolveInteractionIdentityState( pronounConfidence: 1, pronounGuidance: `Any of these pronoun sets are explicitly acceptable for this speaker: ${explicitPreferredSets.join(", ")}. Avoid pronoun sets they explicitly rejected.`, pronounEvidence: normalizedEvidence, + socialReadEvidence: [], }; } @@ -644,6 +958,7 @@ function resolveInteractionIdentityState( pronounConfidence: winning.confidence, pronounGuidance: `Use ${winning.pronounSet} for this speaker. This preference came from an explicit statement or correction and should override softer contextual guesses.`, pronounEvidence: normalizedEvidence, + socialReadEvidence: [], }; } @@ -669,6 +984,7 @@ function resolveInteractionIdentityState( pronounGuidance: "Pronoun evidence exists, but it does not establish a clear usable preference yet. Use the speaker's name or neutral phrasing unless they clarify.", pronounEvidence: normalizedEvidence, + socialReadEvidence: [], }; } @@ -679,6 +995,7 @@ function resolveInteractionIdentityState( pronounGuidance: "Pronoun evidence for this speaker is conflicted or too close to call. Avoid guessing; use their name or neutral phrasing unless they clarify.", pronounEvidence: normalizedEvidence, + socialReadEvidence: [], }; } @@ -691,6 +1008,7 @@ function resolveInteractionIdentityState( pronounConfidence: confidence, pronounGuidance: `Prefer ${winner[0]} for this speaker based on accumulated contextual evidence, but switch immediately if they or the room explicitly correct it.`, pronounEvidence: normalizedEvidence, + socialReadEvidence: [], }; } @@ -728,3 +1046,26 @@ function weightPronounEvidence(entry: PronounEvidence): number { return base * clamp(entry.confidence, 0, 1); } + +function dedupeSocialReadEvidence( + evidence: StoredTranscriptParticipantRead[], +): StoredTranscriptParticipantRead[] { + const deduped = new Map(); + + for (const entry of evidence) { + const key = [ + entry.actorId, + entry.observedAt, + entry.summary.trim().toLowerCase(), + ].join("::"); + const existing = deduped.get(key); + + if (!existing || existing.observedAt < entry.observedAt) { + deduped.set(key, entry); + } + } + + return [...deduped.values()] + .sort((left, right) => right.observedAt.localeCompare(left.observedAt)) + .slice(0, MAX_SOCIAL_READ_EVIDENCE); +} diff --git a/packages/core/src/interaction-memory.ts b/packages/core/src/interaction-memory.ts index f1e51d2..ea1befd 100644 --- a/packages/core/src/interaction-memory.ts +++ b/packages/core/src/interaction-memory.ts @@ -4,12 +4,14 @@ import { dirname } from "node:path"; import { type InteractionMemoryProfile, type PronounEvidence, + type StoredTranscriptParticipantRead, } from "@voidbot/shared"; import { buildInteractionMemoryEvent, emptyInteractionProfile, mergePronounEvidenceIntoIdentityState, + mergeSocialReadEvidenceIntoIdentityState, MAX_RECENT_INTERACTION_EVENTS, normalizeInteractionIdentityState, normalizeInteractionEvent, @@ -31,6 +33,9 @@ export interface InteractionMemoryBank { actorName: string, evidence: PronounEvidence[], ): Promise; + recordSocialReadEvidence( + evidence: StoredTranscriptParticipantRead[], + ): Promise; } export type { RecordInteractionInput } from "./interaction-memory-logic"; @@ -47,7 +52,11 @@ export class FileInteractionMemoryBank implements InteractionMemoryBank { const store = await this.readUnlocked(); const profile = store.profiles.find((candidate) => candidate.actorId === actorId); return profile && - (profile.totalInteractions > 0 || profile.pronounEvidence.length > 0) + ( + profile.totalInteractions > 0 || + profile.pronounEvidence.length > 0 || + profile.socialReadEvidence.length > 0 + ) ? structuredClone(profile) : undefined; } @@ -84,7 +93,8 @@ export class FileInteractionMemoryBank implements InteractionMemoryBank { if ( nextProfile.totalInteractions === 0 && - nextProfile.pronounEvidence.length === 0 + nextProfile.pronounEvidence.length === 0 && + nextProfile.socialReadEvidence.length === 0 ) { if (existingProfileIndex !== -1) { store.profiles.splice(existingProfileIndex, 1); @@ -100,6 +110,46 @@ export class FileInteractionMemoryBank implements InteractionMemoryBank { }); } + public async recordSocialReadEvidence( + evidence: StoredTranscriptParticipantRead[], + ): Promise { + if (evidence.length === 0) { + return; + } + + await this.serialize(async () => { + const store = await this.readUnlocked(); + + for (const entry of evidence) { + const existingProfileIndex = store.profiles.findIndex( + (candidate) => candidate.actorId === entry.actorId, + ); + const existingProfile = + existingProfileIndex === -1 + ? emptyInteractionProfile(entry.actorId, entry.actorName) + : store.profiles[existingProfileIndex]!; + const mergedIdentityState = mergeSocialReadEvidenceIntoIdentityState( + existingProfile, + [entry], + ); + const nextProfile = summarizeInteractionProfile( + entry.actorId, + entry.actorName, + existingProfile.recentEvents, + mergedIdentityState, + ); + + if (existingProfileIndex === -1) { + store.profiles.push(nextProfile); + } else { + store.profiles[existingProfileIndex] = nextProfile; + } + } + + await this.writeUnlocked(store); + }); + } + public async recordPronounEvidence( actorId: string, actorName: string, @@ -195,7 +245,9 @@ function normalizeStore(store: InteractionMemoryStore): InteractionMemoryStore { )) .filter( (profile) => - profile.totalInteractions > 0 || profile.pronounEvidence.length > 0, + profile.totalInteractions > 0 || + profile.pronounEvidence.length > 0 || + profile.socialReadEvidence.length > 0, ), }; } diff --git a/packages/core/src/situational-social-read.ts b/packages/core/src/situational-social-read.ts index 299009f..dd9a3b4 100644 --- a/packages/core/src/situational-social-read.ts +++ b/packages/core/src/situational-social-read.ts @@ -5,10 +5,26 @@ import { type PronounEvidenceSource, type PronounEvidenceStance, type PronounSet, + socialReadBehavioralDimensionKeys, + socialReadPresentationStrategyKeys, + socialReadSituationalStateKeys, + socialReadStableDispositionKeys, + socialReadUnderlyingOrganizationKeys, + socialReadVoiceStyleKeys, type SituationalSocialRead, type SourceMessage, + type TranscriptParticipantRead, } from "@voidbot/shared"; +import { + BEHAVIORAL_DIMENSION_DESCRIPTORS, + PRESENTATION_STRATEGY_DESCRIPTORS, + SITUATIONAL_STATE_DESCRIPTORS, + STABLE_DISPOSITION_DESCRIPTORS, + UNDERLYING_ORGANIZATION_DESCRIPTORS, + VOICE_STYLE_DESCRIPTORS, +} from "./social-read-glossary"; + interface SituationalSocialReadInput { prompt: string; actor: Actor; @@ -16,6 +32,11 @@ interface SituationalSocialReadInput { interactionMemory?: InteractionMemoryProfile; } +interface ParticipantRosterEntry { + actorId: string; + actorName: string; +} + type JsonSchema = Record; interface InferSituationalSocialReadRequestBody { @@ -50,70 +71,38 @@ export interface OllamaSituationalSocialReadInfererOptions { const MAX_RECENT_MESSAGES = 12; const MAX_MESSAGE_CHARS = 280; -const SITUATIONAL_SOCIAL_READ_SCHEMA: JsonSchema = { + +const PRONOUN_EVIDENCE_SCHEMA = { type: "object", additionalProperties: false, properties: { - summary: { type: "string" }, - roomTone: { type: "string" }, - speakerCurrentRead: { type: "string" }, - socialFrame: { type: "string" }, - responseGuidance: { type: "string" }, - supportingSignals: { - type: "array", - items: { type: "string" }, + pronounSet: { + type: "string", + enum: ["they/them", "he/him", "she/her"], }, - pronounEvidence: { - type: "array", - items: { - type: "object", - additionalProperties: false, - properties: { - pronounSet: { - type: "string", - enum: ["they/them", "he/him", "she/her"], - }, - source: { - type: "string", - enum: [ - "explicit_self_statement", - "explicit_correction", - "direct_third_party_statement", - "contextual_relational_inference", - "ambient_usage", - ], - }, - stance: { - type: "string", - enum: ["prefer", "avoid"], - }, - confidence: { - type: "number", - minimum: 0, - maximum: 1, - }, - excerpt: { type: "string" }, - }, - required: [ - "pronounSet", - "source", - "stance", - "confidence", - "excerpt", - ], - }, + source: { + type: "string", + enum: [ + "explicit_self_statement", + "explicit_correction", + "direct_third_party_statement", + "contextual_relational_inference", + "ambient_usage", + ], }, + stance: { + type: "string", + enum: ["prefer", "avoid"], + }, + confidence: { + type: "number", + minimum: 0, + maximum: 1, + }, + excerpt: { type: "string" }, }, - required: [ - "summary", - "roomTone", - "speakerCurrentRead", - "socialFrame", - "responseGuidance", - "supportingSignals", - "pronounEvidence", - ], -}; + required: ["pronounSet", "source", "stance", "confidence", "excerpt"], +} satisfies JsonSchema; export class OllamaSituationalSocialReadInferer { public constructor( @@ -127,22 +116,28 @@ export class OllamaSituationalSocialReadInferer { const recentMessages = (input.recentMessages ?? []) .filter((message) => message.content.trim().length > 0) .slice(-MAX_RECENT_MESSAGES); + const participantRoster = buildParticipantRoster(input.actor, recentMessages); - if (prompt.length === 0 && recentMessages.length === 0 && !input.interactionMemory) { + if ( + prompt.length === 0 && + recentMessages.length === 0 && + !input.interactionMemory && + participantRoster.length === 0 + ) { return undefined; } const controller = new AbortController(); const timeoutHandle = setTimeout( () => controller.abort(), - Math.min(this.options.ollamaTimeoutMs, 30_000), + this.options.ollamaTimeoutMs, ); try { const rawContent = await this.requestStructuredJson( buildSystemPrompt(), - buildUserPrompt(input, recentMessages), - SITUATIONAL_SOCIAL_READ_SCHEMA, + buildUserPrompt(input, recentMessages, participantRoster), + buildSituationalSocialReadSchema(participantRoster), controller.signal, ); @@ -150,12 +145,7 @@ export class OllamaSituationalSocialReadInferer { return undefined; } - const parsed = parseSituationalSocialRead(rawContent); - - if (!parsed) { - return undefined; - } - return parsed; + return parseSituationalSocialRead(rawContent, input.actor.id); } catch (error) { if ((error as Error).name === "AbortError") { throw new Error( @@ -220,7 +210,7 @@ export class OllamaSituationalSocialReadInferer { function buildSystemPrompt(): string { return [ "You are producing private room-reading scaffolding for a Discord bot reply.", - "Read the recent room context and infer only what is useful for this one reply.", + "Read the current prompt plus recent room context and infer only what is useful for this one reply.", "Do not diagnose, moralize, or write therapy notes.", "Do not infer more certainty than the evidence supports.", "This read is private scaffolding and must stay concise, practical, and grounded in visible behavior.", @@ -231,28 +221,49 @@ function buildSystemPrompt(): string { '- "socialFrame": what kind of interaction this is and how it should be framed', '- "responseGuidance": private guidance for the final reply model', '- "supportingSignals": an array of short evidence bullets tied to the visible context', - '- "pronounEvidence": an array of evidence objects about the current speaker only, each with "pronounSet", "source", "stance", "confidence", and "excerpt"', - "Treat the current prompt itself as valid room context for pronoun evidence and social framing.", - "If the current speaker explicitly states acceptable pronouns or explicitly rejects a pronoun, emit that evidence here even if no prior transcript is attached.", - "If the speaker explicitly accepts multiple pronoun sets, emit one evidence object per accepted set.", + '- "participantReads": one structured participant profile for every non-bot human visible in the transcript, plus the current speaker if they are not already visible there', + "participantReads are the primary output. The room summary fields are secondary scaffolding.", + "Each participantRead is a binary detection pass over five durable Ghostlight label families: underlying organization, stable dispositions, behavioral dimensions, presentation strategy, and voice style.", + "Each participantRead also includes an ephemeral situationalState array for what looks activated right now in this specific moment. Situational state is current pressure, not durable identity truth.", + "Only emit labels that have real visible support in the attached prompt or transcript. Leave the label out if the evidence is weak or absent.", + "Never leave participantReads empty when a participant roster was provided. If the evidence is sparse, still emit the participantRead with a brief summary, sparse arrays, and any pronoun evidence you can justify.", + "For pronounEvidence inside each participantRead, only emit evidence grounded in the visible transcript or current prompt. Never guess from names alone.", + "If a participant explicitly states their acceptable pronouns in the current prompt or transcript, their participantRead must include pronounEvidence for those sets. Do not leave pronounEvidence empty in that case.", + "Treat the current prompt itself as valid room context for both social framing and participant profiling.", + "If a participant explicitly states acceptable pronouns or explicitly rejects a pronoun, emit that evidence for them even with no prior transcript.", + "If a participant explicitly accepts multiple pronoun sets, emit one evidence object per accepted set.", + "Ghostlight underlying organization labels:", + renderLabelGlossary(UNDERLYING_ORGANIZATION_DESCRIPTORS), + "Ghostlight stable disposition labels:", + renderLabelGlossary(STABLE_DISPOSITION_DESCRIPTORS), + "Ghostlight behavioral dimension labels:", + renderLabelGlossary(BEHAVIORAL_DIMENSION_DESCRIPTORS), + "Ghostlight presentation strategy labels:", + renderLabelGlossary(PRESENTATION_STRATEGY_DESCRIPTORS), + "Ghostlight voice style labels:", + renderLabelGlossary(VOICE_STYLE_DESCRIPTORS), + "Ghostlight situational state labels:", + renderLabelGlossary(SITUATIONAL_STATE_DESCRIPTORS), 'Use only these pronoun sets: "they/them", "he/him", "she/her".', - 'Use only these evidence sources: "explicit_self_statement", "explicit_correction", "direct_third_party_statement", "contextual_relational_inference", "ambient_usage".', - 'Use stance "prefer" when the speaker accepts a pronoun set and "avoid" when the speaker explicitly rejects it.', - 'If there is no real pronoun evidence, return "pronounEvidence": [].', - "If the evidence is weak, say so plainly inside the fields instead of inventing drama.", + 'Use only these pronoun evidence sources: "explicit_self_statement", "explicit_correction", "direct_third_party_statement", "contextual_relational_inference", "ambient_usage".', + 'Use pronoun stance "prefer" when the participant accepts a pronoun set and "avoid" when they explicitly reject it.', + "If evidence is weak, stay sparse rather than hallucinating a personality zoo.", + "Minimal participantRead example:", + '{"actorId":"123","actorName":"Example User","summary":"Asked a direct clarifying question and stated a pronoun preference.","underlyingOrganization":[],"stableDispositions":[],"behavioralDimensions":["suspicion"],"presentationStrategies":[],"voiceStyle":["plainspoken_directness"],"situationalState":["perceived_status_threat"],"pronounEvidence":[{"pronounSet":"they/them","source":"explicit_self_statement","stance":"prefer","confidence":1,"excerpt":"call me by they/them preferably"}],"supportingSignals":["They asked a direct challenge question.","They explicitly requested they/them pronouns."]}', ].join("\n"); } function buildUserPrompt( input: SituationalSocialReadInput, recentMessages: SourceMessage[], + participantRoster: ParticipantRosterEntry[], ): string { const recentTranscript = recentMessages.length > 0 ? recentMessages .map( (message) => - `- [${message.timestamp}] ${message.authorName}${message.isBot ? " (bot)" : ""}: ${truncate(message.content, MAX_MESSAGE_CHARS)}`, + `- [${message.timestamp}] ${message.authorName} (${message.authorId})${message.isBot ? " (bot)" : ""}: ${truncate(message.content, MAX_MESSAGE_CHARS)}`, ) .join("\n") : "- No recent room transcript was attached."; @@ -263,6 +274,12 @@ function buildUserPrompt( `Private response guidance: ${input.interactionMemory.responseGuidance}`, ].join("\n") : "No explicit long-horizon interaction memory was attached."; + const participantLines = + participantRoster.length > 0 + ? participantRoster + .map((participant) => `- ${participant.actorName} (${participant.actorId})`) + .join("\n") + : "- No participant roster was derived."; return [ `Current speaker: ${input.actor.displayName} (${input.actor.id})`, @@ -276,15 +293,136 @@ function buildUserPrompt( "Longer-horizon interaction memory:", interactionMemory, "", + "Participants to profile exactly once each:", + participantLines, + "", "Infer a private situational social read for this one reply.", - "If you emit pronounEvidence, it must be about the current speaker rather than unrelated third parties.", - "Ground it in the visible room context and the current prompt.", + "Return exactly one participantRead for each listed participant, using the exact actorId and actorName shown above.", + "Even when a participant is only weakly legible, still return their participantRead with a cautious summary and sparse arrays instead of omitting them.", + "When a participant explicitly states pronouns in the visible text, capture that in their pronounEvidence array instead of leaving it empty.", + "Ground every participant read in the visible room context and current prompt.", "Do not output anything except the requested JSON object.", ].join("\n"); } +function buildParticipantReadSchema( + participant: ParticipantRosterEntry, +): JsonSchema { + return { + type: "object", + additionalProperties: false, + properties: { + actorId: { type: "string", const: participant.actorId }, + actorName: { type: "string", const: participant.actorName }, + summary: { type: "string" }, + underlyingOrganization: { + type: "array", + items: { + type: "string", + enum: [...socialReadUnderlyingOrganizationKeys], + }, + }, + stableDispositions: { + type: "array", + items: { + type: "string", + enum: [...socialReadStableDispositionKeys], + }, + }, + behavioralDimensions: { + type: "array", + items: { + type: "string", + enum: [...socialReadBehavioralDimensionKeys], + }, + }, + presentationStrategies: { + type: "array", + items: { + type: "string", + enum: [...socialReadPresentationStrategyKeys], + }, + }, + voiceStyle: { + type: "array", + items: { + type: "string", + enum: [...socialReadVoiceStyleKeys], + }, + }, + situationalState: { + type: "array", + items: { + type: "string", + enum: [...socialReadSituationalStateKeys], + }, + }, + pronounEvidence: { + type: "array", + items: PRONOUN_EVIDENCE_SCHEMA, + }, + supportingSignals: { + type: "array", + items: { type: "string" }, + }, + }, + required: [ + "actorId", + "actorName", + "summary", + "underlyingOrganization", + "stableDispositions", + "behavioralDimensions", + "presentationStrategies", + "voiceStyle", + "situationalState", + "pronounEvidence", + "supportingSignals", + ], + } satisfies JsonSchema; +} + +function buildSituationalSocialReadSchema( + participantRoster: ParticipantRosterEntry[], +): JsonSchema { + return { + type: "object", + additionalProperties: false, + properties: { + summary: { type: "string" }, + roomTone: { type: "string" }, + speakerCurrentRead: { type: "string" }, + socialFrame: { type: "string" }, + responseGuidance: { type: "string" }, + supportingSignals: { + type: "array", + items: { type: "string" }, + }, + participantReads: { + type: "array", + prefixItems: participantRoster.map((participant) => + buildParticipantReadSchema(participant), + ), + items: false, + minItems: participantRoster.length, + maxItems: participantRoster.length, + }, + }, + required: [ + "summary", + "roomTone", + "speakerCurrentRead", + "socialFrame", + "responseGuidance", + "supportingSignals", + "participantReads", + ], + } satisfies JsonSchema; +} + function parseSituationalSocialRead( input: string, + currentActorId: string, ): SituationalSocialRead | undefined { const normalized = unwrapStructuredFence(input); @@ -300,7 +438,7 @@ function parseSituationalSocialRead( const socialFrame = normalizeModelText(parsed.socialFrame); const responseGuidance = normalizeModelText(parsed.responseGuidance); const supportingSignals = normalizeStringArray(parsed.supportingSignals); - const pronounEvidence = normalizePronounEvidenceArray(parsed.pronounEvidence); + const participantReads = normalizeParticipantReadArray(parsed.participantReads); if ( !summary || @@ -312,6 +450,10 @@ function parseSituationalSocialRead( return undefined; } + const currentParticipantRead = + participantReads.find((entry) => entry.actorId === currentActorId) ?? + participantReads[0]; + return { summary, roomTone, @@ -319,7 +461,8 @@ function parseSituationalSocialRead( socialFrame, responseGuidance, supportingSignals, - pronounEvidence, + pronounEvidence: currentParticipantRead?.pronounEvidence ?? [], + participantReads, }; } catch { return undefined; @@ -336,6 +479,79 @@ function normalizeStringArray(value: unknown): string[] { .filter((entry): entry is string => Boolean(entry)); } +function normalizeParticipantReadArray(value: unknown): TranscriptParticipantRead[] { + if (!Array.isArray(value)) { + return []; + } + + return value + .map((entry) => normalizeParticipantRead(entry)) + .filter((entry): entry is TranscriptParticipantRead => entry !== undefined); +} + +function normalizeParticipantRead(value: unknown): TranscriptParticipantRead | undefined { + if (!value || typeof value !== "object") { + return undefined; + } + + const record = value as Record; + const actorId = normalizeModelText(record.actorId); + const actorName = normalizeModelText(record.actorName); + const summary = normalizeModelText(record.summary); + const underlyingOrganization = normalizeEnumArray( + record.underlyingOrganization, + socialReadUnderlyingOrganizationKeys, + ); + const stableDispositions = normalizeEnumArray( + record.stableDispositions, + socialReadStableDispositionKeys, + ); + const behavioralDimensions = normalizeEnumArray( + record.behavioralDimensions, + socialReadBehavioralDimensionKeys, + ); + const presentationStrategies = normalizeEnumArray( + record.presentationStrategies, + socialReadPresentationStrategyKeys, + ); + const voiceStyle = normalizeEnumArray(record.voiceStyle, socialReadVoiceStyleKeys); + const situationalState = normalizeEnumArray( + record.situationalState, + socialReadSituationalStateKeys, + ); + const pronounEvidence = normalizePronounEvidenceArray(record.pronounEvidence); + const supportingSignals = normalizeStringArray(record.supportingSignals); + + if (!actorId || !actorName || !summary) { + return undefined; + } + + return { + actorId, + actorName, + summary, + underlyingOrganization, + stableDispositions, + behavioralDimensions, + presentationStrategies, + voiceStyle, + situationalState, + pronounEvidence, + supportingSignals, + }; +} + +function normalizeEnumArray( + value: unknown, + allowed: readonly T[], +): T[] { + if (!Array.isArray(value)) { + return []; + } + + return value.filter((entry): entry is T => allowed.includes(entry as T)); +} + function normalizePronounEvidenceArray(value: unknown): PronounEvidence[] { if (!Array.isArray(value)) { return []; @@ -432,3 +648,38 @@ function truncate(value: string, maxLength: number): string { return `${normalized.slice(0, maxLength - 3)}...`; } + +function renderLabelGlossary( + definitions: Record, +): string { + return Object.entries(definitions) + .map(([key, descriptor]) => `- ${key}: ${descriptor.label}. ${descriptor.description}`) + .join("\n"); +} + +function buildParticipantRoster( + actor: Actor, + recentMessages: SourceMessage[], +): ParticipantRosterEntry[] { + const roster = new Map(); + + if (!actor.isBot) { + roster.set(actor.id, { + actorId: actor.id, + actorName: actor.displayName, + }); + } + + for (const message of recentMessages) { + if (message.isBot) { + continue; + } + + roster.set(message.authorId, { + actorId: message.authorId, + actorName: message.authorName, + }); + } + + return [...roster.values()]; +} diff --git a/packages/core/src/social-read-glossary.ts b/packages/core/src/social-read-glossary.ts new file mode 100644 index 0000000..29b98fe --- /dev/null +++ b/packages/core/src/social-read-glossary.ts @@ -0,0 +1,373 @@ +import type { + SocialReadBehavioralDimensionKey, + SocialReadPresentationStrategyKey, + SocialReadSituationalStateKey, + SocialReadStableDispositionKey, + SocialReadUnderlyingOrganizationKey, + SocialReadVoiceStyleKey, +} from "@voidbot/shared"; + +export interface SocialReadDescriptor { + label: string; + description: string; +} + +export const UNDERLYING_ORGANIZATION_DESCRIPTORS: Record< + SocialReadUnderlyingOrganizationKey, + SocialReadDescriptor +> = { + self_coherence: { + label: "Self-Coherence", + description: "How integrated and stable the person's sense of self seems under pressure.", + }, + contingent_worth: { + label: "Contingent Worth", + description: + "Whether their felt worth appears tied to approval, utility, status, purity, or validation.", + }, + shame_sensitivity: { + label: "Shame Sensitivity", + description: "Whether exposure, correction, failure, or diminishment seems especially painful.", + }, + reciprocity_capacity: { + label: "Reciprocity Capacity", + description: + "Whether they seem able to sustain mutual obligations instead of purely extractive or avoidant relations.", + }, + mentalization_quality: { + label: "Mentalization Quality", + description: + "Whether they model other minds with nuance instead of flattening them into crude threat, need, or utility shapes.", + }, + authenticity_tolerance: { + label: "Authenticity Tolerance", + description: + "Whether they can be known without immediately retreating into performance, concealment, or control.", + }, + mask_rigidity: { + label: "Mask Rigidity", + description: "Whether the performed self seems inflexible or load-bearing.", + }, + external_regulation_dependence: { + label: "External Regulation Dependence", + description: + "Whether emotional stability appears to depend heavily on other people, scripts, institutions, or external structures.", + }, +}; + +export const STABLE_DISPOSITION_DESCRIPTORS: Record< + SocialReadStableDispositionKey, + SocialReadDescriptor +> = { + novelty_seeking: { + label: "Novelty-Seeking", + description: "Attraction to new experience, strange opportunities, or unproven paths.", + }, + conformity: { + label: "Conformity", + description: "Preference for accepted norms, procedures, and group expectations.", + }, + status_hunger: { + label: "Status Hunger", + description: "Desire for rank, prestige, visible recognition, or superiority.", + }, + risk_tolerance: { + label: "Risk Tolerance", + description: "Willingness to accept danger, uncertainty, or loss for gain or freedom.", + }, + sociability: { + label: "Sociability", + description: "Baseline draw toward company, conversation, and social energy.", + }, + baseline_threat_sensitivity: { + label: "Baseline Threat Sensitivity", + description: + "Default readiness to detect danger, betrayal, humiliation, or exploitation.", + }, + aesthetic_appetite: { + label: "Aesthetic Appetite", + description: + "Sensitivity to beauty, style, symbolic form, taste, or expressive environment.", + }, + ideological_rigidity: { + label: "Ideological Rigidity", + description: "Resistance to revising beliefs, myths, doctrines, or explanatory frames.", + }, +}; + +export const BEHAVIORAL_DIMENSION_DESCRIPTORS: Record< + SocialReadBehavioralDimensionKey, + SocialReadDescriptor +> = { + interpersonal_warmth: { + label: "Interpersonal Warmth", + description: "Tendency to express care, friendliness, affection, or social welcome.", + }, + drive: { + label: "Drive", + description: "Goal pressure, persistence, ambition, and forward force.", + }, + grandiosity: { + label: "Grandiosity", + description: + "Inflated self-importance, entitlement, exceptionalism, or self-mythologizing.", + }, + validation_seeking: { + label: "Validation-Seeking", + description: "Need for reassurance, approval, recognition, or confirmation of worth.", + }, + anxiety: { + label: "Anxiety", + description: "Anticipatory fear, worry, nervous vigilance, or instability under uncertainty.", + }, + control_pressure: { + label: "Control Pressure", + description: "Urge to manage people, situations, information, or outcomes tightly.", + }, + hostility: { + label: "Hostility", + description: "Readiness toward anger, contempt, antagonism, attack, or punishment.", + }, + suspicion: { + label: "Suspicion", + description: "Expectation that others hide motives, traps, threats, or bad faith.", + }, + rigidity: { + label: "Rigidity", + description: "Difficulty adapting behavior, plans, or interpretation under new evidence.", + }, + withdrawal: { + label: "Withdrawal", + description: "Tendency to disengage, retreat, shut down, or reduce availability.", + }, + volatility: { + label: "Volatility", + description: "Speed and intensity of emotional swings or escalation.", + }, + attachment_seeking: { + label: "Attachment-Seeking", + description: + "Pull toward closeness, reassurance, privileged access, fusion, or being chosen.", + }, + distance_seeking: { + label: "Distance-Seeking", + description: + "Push toward space, opacity, autonomy, and reduced emotional claim from others.", + }, +}; + +export const PRESENTATION_STRATEGY_DESCRIPTORS: Record< + SocialReadPresentationStrategyKey, + SocialReadDescriptor +> = { + charm: { + label: "Charm", + description: "Performs warmth, ease, charisma, or pleasantness to influence or smooth contact.", + }, + compliance: { + label: "Compliance", + description: + "Performs agreement, submission, helpfulness, or nonthreatening cooperation.", + }, + superiority: { + label: "Superiority", + description: + "Performs being above others, more competent, more refined, or less vulnerable.", + }, + detachment: { + label: "Detachment", + description: "Performs cool distance, emotional unavailability, or not-needing.", + }, + seductiveness: { + label: "Seductiveness", + description: "Performs desirability, invitation, or intimate leverage.", + }, + competence_theater: { + label: "Competence Theater", + description: + "Performs capability and control, sometimes beyond what is actually secure.", + }, + moral_theater: { + label: "Moral Theater", + description: "Performs righteousness, purity, sacrifice, or ethical authority.", + }, + strategic_opacity: { + label: "Strategic Opacity", + description: + "Controls what others can know; hides motives, pain, dependency, or plans.", + }, + cultivated_harmlessness: { + label: "Cultivated Harmlessness", + description: "Performs being safe, small, useful, cute, or beneath concern.", + }, + abrasive_boundary: { + label: "Abrasive Boundary", + description: "Performs difficulty, bite, or unpleasantness to keep others from pressing closer.", + }, + ironic_distance: { + label: "Ironic Distance", + description: "Performs irony, detachment, or joking distance to avoid naked sincerity.", + }, +}; + +export const VOICE_STYLE_DESCRIPTORS: Record< + SocialReadVoiceStyleKey, + SocialReadDescriptor +> = { + dryness: { label: "Dryness", description: "Understated, deadpan, low-sentiment phrasing." }, + verbal_warmth: { + label: "Verbal Warmth", + description: "Inviting, affectionate, reassuring, or socially soft phrasing.", + }, + formality: { + label: "Formality", + description: "Uses formal structure, titles, careful address, or institutionally correct phrasing.", + }, + verbosity: { + label: "Verbosity", + description: "Tends toward longer turns, elaboration, qualification, or verbal sprawl.", + }, + pace: { + label: "Pace", + description: "Moves quickly through turns, interruptions, replies, or topic shifts.", + }, + plainspoken_directness: { + label: "Plainspoken Directness", + description: "Speaks plainly, concretely, or bluntly rather than ornamenting or obscuring.", + }, + lexical_precision: { + label: "Lexical Precision", + description: "Chooses exact words, distinctions, definitions, or careful terms.", + }, + technical_density: { + label: "Technical Density", + description: "Packs speech with specialist terms, systems language, procedure, or analysis.", + }, + technical_compression: { + label: "Technical Compression", + description: "Compresses technical meaning into terse expert shorthand.", + }, + figurative_language: { + label: "Figurative Language", + description: "Uses metaphor, image, analogy, poetic compression, or symbolic framing.", + }, + lyricism: { + label: "Lyricism", + description: "Uses musical, poetic, sensuous, or rhythmically heightened language.", + }, + narrative_detail: { + label: "Narrative Detail", + description: "Explains through context, sequence, anecdote, or concrete scene detail.", + }, + emotional_explicitness: { + label: "Emotional Explicitness", + description: "Names feelings, needs, wounds, affection, fear, or attachment directly.", + }, + pointedness: { + label: "Pointedness", + description: "Cuts directly, sharply, or with barbed precision.", + }, + self_disclosure: { + label: "Self-Disclosure", + description: "Volunteers personal history, inner state, motives, or private stakes.", + }, + hedging: { + label: "Hedging", + description: "Softens claims with uncertainty markers, caveats, deference, or exits.", + }, + certainty_marking: { + label: "Certainty Marking", + description: "Signals confidence, finality, authority, or refusal to leave claims open.", + }, + politeness: { + label: "Politeness", + description: "Uses courtesy, mitigation, face-saving language, or social smoothing.", + }, + coded_politeness: { + label: "Coded Politeness", + description: "Uses polite phrasing to imply criticism, threat, refusal, hierarchy, or hidden meaning.", + }, + ritualized_address: { + label: "Ritualized Address", + description: "Uses formulaic greetings, titles, honorifics, oaths, prayers, or ceremonial phrases.", + }, + register_switching: { + label: "Register Switching", + description: "Shifts between speech registers depending on audience, status, danger, or role.", + }, + dialect_marking: { + label: "Dialect Marking", + description: "Shows regional, class, occupational, subcultural, or community-specific speech markers.", + }, + theatricality: { + label: "Theatricality", + description: "Performs speech with heightened drama, staging, persona, flourish, or rhetorical display.", + }, + humor: { + label: "Humor", + description: "Uses jokes, wit, absurdity, teasing, or comic framing as a regular speech tool.", + }, + conversational_dominance: { + label: "Conversational Dominance", + description: "Takes, holds, redirects, or controls conversational floor and agenda.", + }, + listening_responsiveness: { + label: "Listening Responsiveness", + description: "Reflects, tracks, validates, or adapts to what the other person just said.", + }, + question_asking: { + label: "Question-Asking", + description: "Uses questions to probe, invite, corner, teach, test, or keep the other person talking.", + }, + profanity: { + label: "Profanity", + description: "Uses taboo, vulgar, sacred, or deliberately coarse language.", + }, +}; + +export const SITUATIONAL_STATE_DESCRIPTORS: Record< + SocialReadSituationalStateKey, + SocialReadDescriptor +> = { + exhaustion: { + label: "Exhaustion", + description: "Current depletion, fatigue, overuse, or low reserve.", + }, + scarcity_pressure: { + label: "Scarcity Pressure", + description: "Pressure from money, supplies, access, time, space, safety, or opportunity being scarce.", + }, + humiliation: { + label: "Humiliation", + description: "Current felt diminishment, exposure, embarrassment, or status wound.", + }, + panic: { + label: "Panic", + description: "Acute fear, urgency, overwhelm, or threat response.", + }, + triumph: { + label: "Triumph", + description: "Current victory, vindication, high confidence, or emotional lift.", + }, + grief: { + label: "Grief", + description: "Active loss, mourning, sorrow, or ache.", + }, + overstimulation: { + label: "Overstimulation", + description: "Current sensory, social, cognitive, or emotional overload.", + }, + grievance_activation: { + label: "Grievance Activation", + description: "Active resentment, injustice memory, or retaliatory moral charge.", + }, + acute_shame: { + label: "Acute Shame", + description: "Immediate shame flare, exposure pain, or self-disgust.", + }, + perceived_status_threat: { + label: "Perceived Status Threat", + description: "Current sense that rank, dignity, competence, or face is under threat.", + }, +}; + diff --git a/packages/core/src/state-storage-postgres-bootstrap.ts b/packages/core/src/state-storage-postgres-bootstrap.ts index f2ccb52..78319c4 100644 --- a/packages/core/src/state-storage-postgres-bootstrap.ts +++ b/packages/core/src/state-storage-postgres-bootstrap.ts @@ -69,7 +69,7 @@ export async function migrateLegacyFileStateIfNeeded( } for (const profile of profiles) { - if (profile.pronounEvidence.length === 0) { + if (profile.pronounEvidence.length === 0 && profile.socialReadEvidence.length === 0) { continue; } @@ -84,6 +84,7 @@ export async function migrateLegacyFileStateIfNeeded( pronounConfidence: profile.pronounConfidence, pronounGuidance: profile.pronounGuidance, pronounEvidence: profile.pronounEvidence, + socialReadEvidence: profile.socialReadEvidence, }, ); } diff --git a/packages/core/src/state-storage-postgres-interaction-memory.ts b/packages/core/src/state-storage-postgres-interaction-memory.ts index 4de0d58..d36725c 100644 --- a/packages/core/src/state-storage-postgres-interaction-memory.ts +++ b/packages/core/src/state-storage-postgres-interaction-memory.ts @@ -4,11 +4,13 @@ import { type InteractionMemoryEvent, type InteractionMemoryProfile, type PronounEvidence, + type StoredTranscriptParticipantRead, } from "@voidbot/shared"; import { buildInteractionMemoryEvent, mergePronounEvidenceIntoIdentityState, + mergeSocialReadEvidenceIntoIdentityState, normalizeInteractionIdentityState, type RecordInteractionInput, shouldPersistInteractionEvent, @@ -47,7 +49,11 @@ export class PostgresInteractionMemoryBank implements InteractionMemoryBank { identityState, ); - return profile.totalInteractions > 0 || profile.pronounEvidence.length > 0 + return ( + profile.totalInteractions > 0 || + profile.pronounEvidence.length > 0 || + profile.socialReadEvidence.length > 0 + ) ? profile : undefined; } @@ -110,6 +116,28 @@ export class PostgresInteractionMemoryBank implements InteractionMemoryBank { return summarizeInteractionProfile(actorId, actorName, existingEvents, mergedIdentityState); } + public async recordSocialReadEvidence( + evidence: StoredTranscriptParticipantRead[], + ): Promise { + if (evidence.length === 0) { + return; + } + + for (const entry of evidence) { + const mergedIdentityState = mergeSocialReadEvidenceIntoIdentityState( + (await this.getIdentityRecord(entry.actorId))?.state, + [entry], + ); + + await upsertInteractionIdentityState( + this.pool, + entry.actorId, + entry.actorName, + mergedIdentityState, + ); + } + } + private async listActorEvents(actorId: string): Promise { const result = await this.pool.query<{ event_json: unknown }>( `select event_json diff --git a/packages/providers/src/local-llm-render.ts b/packages/providers/src/local-llm-render.ts index dbbf750..8a54774 100644 --- a/packages/providers/src/local-llm-render.ts +++ b/packages/providers/src/local-llm-render.ts @@ -126,6 +126,7 @@ function renderInteractionMemory(context: ContextBundle): string { `- Current stance: ${context.interactionMemory.disposition}; affinity=${context.interactionMemory.affinityScore}`, `- Private response guidance (do not reveal): ${context.interactionMemory.responseGuidance}`, `- Private pronoun guidance (do not reveal): ${context.interactionMemory.pronounGuidance}`, + `- Transcript-derived profile signals: underlying=${formatCompactLabelList(context.interactionMemory.underlyingOrganizationScores, 3)}; dispositions=${formatCompactLabelList(context.interactionMemory.stableDispositionScores, 3)}; behavioral=${formatCompactLabelList(context.interactionMemory.behavioralDimensionScores, 5)}; presentation=${formatCompactLabelList(context.interactionMemory.presentationStrategyScores, 3)}; voice=${formatCompactLabelList(context.interactionMemory.voiceStyleScores, 5)}`, "- Specific remembered incidents:", recentEvents, ].join("\n"); @@ -136,12 +137,23 @@ function renderSituationalSocialRead(context: ContextBundle): string { return "- No strong situational social read was derived from the immediate room context."; } + const currentSpeakerRead = + context.situationalSocialRead.participantReads.find( + (entry) => entry.actorId === context.actor.id, + ) ?? context.situationalSocialRead.participantReads[0]; + 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}`, + currentSpeakerRead + ? `- Current speaker situational state: ${currentSpeakerRead.situationalState.join(", ") || "none detected"}` + : "- Current speaker situational state: none detected", + currentSpeakerRead + ? `- Current speaker visible labels: behavioral=${currentSpeakerRead.behavioralDimensions.join(", ") || "none"}; presentation=${currentSpeakerRead.presentationStrategies.join(", ") || "none"}; voice=${currentSpeakerRead.voiceStyle.join(", ") || "none"}` + : "- Current speaker visible labels: none detected", context.situationalSocialRead.pronounEvidence.length > 0 ? `- Pronoun cues observed for the current speaker: ${context.situationalSocialRead.pronounEvidence .map( @@ -182,3 +194,17 @@ function renderSourceGroundingInstructions( return `This prompt may benefit from source-side grounding. Use list_indexed_repos, search_sources, or get_source_context if repo, lore, or source evidence would sharpen the answer.${matchedRepos}${reasons}${retry}`; } + +function formatCompactLabelList( + labels: Array<{ label: string; score: number }>, + limit: number, +): string { + if (labels.length === 0) { + return "none"; + } + + return labels + .slice(0, limit) + .map((entry) => `${entry.label}(${entry.score})`) + .join(", "); +} diff --git a/packages/providers/src/owner-codex-shared.ts b/packages/providers/src/owner-codex-shared.ts index 97f2dcd..9c482bd 100644 --- a/packages/providers/src/owner-codex-shared.ts +++ b/packages/providers/src/owner-codex-shared.ts @@ -454,6 +454,7 @@ export function renderInteractionMemory(context: ContextBundle): string { `- Current stance: ${context.interactionMemory.disposition}; affinity=${context.interactionMemory.affinityScore}`, `- Private response guidance (do not reveal): ${context.interactionMemory.responseGuidance}`, `- Private pronoun guidance (do not reveal): ${context.interactionMemory.pronounGuidance}`, + `- Transcript-derived profile signals: underlying=${formatCompactLabelList(context.interactionMemory.underlyingOrganizationScores, 3)}; dispositions=${formatCompactLabelList(context.interactionMemory.stableDispositionScores, 3)}; behavioral=${formatCompactLabelList(context.interactionMemory.behavioralDimensionScores, 5)}; presentation=${formatCompactLabelList(context.interactionMemory.presentationStrategyScores, 3)}; voice=${formatCompactLabelList(context.interactionMemory.voiceStyleScores, 5)}`, "- Specific remembered incidents:", recentEvents, ].join("\n"); @@ -464,12 +465,23 @@ export function renderSituationalSocialRead(context: ContextBundle): string { return "- No strong situational social read was derived from the immediate room context."; } + const currentSpeakerRead = + context.situationalSocialRead.participantReads.find( + (entry) => entry.actorId === context.actor.id, + ) ?? context.situationalSocialRead.participantReads[0]; + 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}`, + currentSpeakerRead + ? `- Current speaker situational state: ${currentSpeakerRead.situationalState.join(", ") || "none detected"}` + : "- Current speaker situational state: none detected", + currentSpeakerRead + ? `- Current speaker visible labels: behavioral=${currentSpeakerRead.behavioralDimensions.join(", ") || "none"}; presentation=${currentSpeakerRead.presentationStrategies.join(", ") || "none"}; voice=${currentSpeakerRead.voiceStyle.join(", ") || "none"}` + : "- Current speaker visible labels: none detected", context.situationalSocialRead.pronounEvidence.length > 0 ? `- Pronoun cues observed for the current speaker: ${context.situationalSocialRead.pronounEvidence .map( @@ -482,3 +494,17 @@ export function renderSituationalSocialRead(context: ContextBundle): string { ...context.situationalSocialRead.supportingSignals.map((signal) => ` ${signal}`), ].join("\n"); } + +function formatCompactLabelList( + labels: Array<{ label: string; score: number }>, + limit: number, +): string { + if (labels.length === 0) { + return "none"; + } + + return labels + .slice(0, limit) + .map((entry) => `${entry.label}(${entry.score})`) + .join(", "); +} diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index e57a63e..860ef33 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -186,6 +186,149 @@ export interface PronounEvidence { timestamp: string; } +export interface ScoredProfileLabel { + key: string; + label: string; + score: number; + summary: string; +} + +export const socialReadUnderlyingOrganizationKeys = [ + "self_coherence", + "contingent_worth", + "shame_sensitivity", + "reciprocity_capacity", + "mentalization_quality", + "authenticity_tolerance", + "mask_rigidity", + "external_regulation_dependence", +] as const; +export type SocialReadUnderlyingOrganizationKey = + (typeof socialReadUnderlyingOrganizationKeys)[number]; + +export const socialReadStableDispositionKeys = [ + "novelty_seeking", + "conformity", + "status_hunger", + "risk_tolerance", + "sociability", + "baseline_threat_sensitivity", + "aesthetic_appetite", + "ideological_rigidity", +] as const; +export type SocialReadStableDispositionKey = + (typeof socialReadStableDispositionKeys)[number]; + +export const socialReadBehavioralDimensionKeys = [ + "interpersonal_warmth", + "drive", + "grandiosity", + "validation_seeking", + "anxiety", + "control_pressure", + "hostility", + "suspicion", + "rigidity", + "withdrawal", + "volatility", + "attachment_seeking", + "distance_seeking", +] as const; +export type SocialReadBehavioralDimensionKey = + (typeof socialReadBehavioralDimensionKeys)[number]; + +export const socialReadPresentationStrategyKeys = [ + "charm", + "compliance", + "superiority", + "detachment", + "seductiveness", + "competence_theater", + "moral_theater", + "strategic_opacity", + "cultivated_harmlessness", + "abrasive_boundary", + "ironic_distance", +] as const; +export type SocialReadPresentationStrategyKey = + (typeof socialReadPresentationStrategyKeys)[number]; + +export const socialReadVoiceStyleKeys = [ + "dryness", + "verbal_warmth", + "formality", + "verbosity", + "pace", + "plainspoken_directness", + "lexical_precision", + "technical_density", + "technical_compression", + "figurative_language", + "lyricism", + "narrative_detail", + "emotional_explicitness", + "pointedness", + "self_disclosure", + "hedging", + "certainty_marking", + "politeness", + "coded_politeness", + "ritualized_address", + "register_switching", + "dialect_marking", + "theatricality", + "humor", + "conversational_dominance", + "listening_responsiveness", + "question_asking", + "profanity", +] as const; +export type SocialReadVoiceStyleKey = + (typeof socialReadVoiceStyleKeys)[number]; + +export const socialReadSituationalStateKeys = [ + "exhaustion", + "scarcity_pressure", + "humiliation", + "panic", + "triumph", + "grief", + "overstimulation", + "grievance_activation", + "acute_shame", + "perceived_status_threat", +] as const; +export type SocialReadSituationalStateKey = + (typeof socialReadSituationalStateKeys)[number]; + +export interface TranscriptParticipantRead { + actorId: string; + actorName: string; + summary: string; + underlyingOrganization: SocialReadUnderlyingOrganizationKey[]; + stableDispositions: SocialReadStableDispositionKey[]; + behavioralDimensions: SocialReadBehavioralDimensionKey[]; + presentationStrategies: SocialReadPresentationStrategyKey[]; + voiceStyle: SocialReadVoiceStyleKey[]; + situationalState: SocialReadSituationalStateKey[]; + pronounEvidence: PronounEvidence[]; + supportingSignals: string[]; +} + +export interface StoredTranscriptParticipantRead { + actorId: string; + actorName: string; + summary: string; + underlyingOrganization: SocialReadUnderlyingOrganizationKey[]; + stableDispositions: SocialReadStableDispositionKey[]; + behavioralDimensions: SocialReadBehavioralDimensionKey[]; + presentationStrategies: SocialReadPresentationStrategyKey[]; + voiceStyle: SocialReadVoiceStyleKey[]; + pronounEvidence: PronounEvidence[]; + supportingSignals: string[]; + observedAt: string; +} + export interface InteractionMemoryProfile { actorId: string; actorName: string; @@ -201,6 +344,11 @@ export interface InteractionMemoryProfile { psychologicalProfile: string; inferredTraits: string[]; interactionDimensions: InteractionMemoryDimension[]; + underlyingOrganizationScores: ScoredProfileLabel[]; + stableDispositionScores: ScoredProfileLabel[]; + behavioralDimensionScores: ScoredProfileLabel[]; + presentationStrategyScores: ScoredProfileLabel[]; + voiceStyleScores: ScoredProfileLabel[]; responseGuidance: string; pronounPolicy: PronounPolicy; resolvedPronounSet?: PronounSet; @@ -208,6 +356,7 @@ export interface InteractionMemoryProfile { pronounConfidence?: number; pronounGuidance: string; pronounEvidence: PronounEvidence[]; + socialReadEvidence: StoredTranscriptParticipantRead[]; lastInteractionAt?: string; recentEvents: InteractionMemoryEvent[]; } @@ -226,6 +375,7 @@ export interface SituationalSocialRead { responseGuidance: string; supportingSignals: string[]; pronounEvidence: PronounEvidence[]; + participantReads: TranscriptParticipantRead[]; } export interface ContextBundle { diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 8c8b6b9..c0e6971 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -30,3 +30,4 @@ {"ts":"2026-05-02T21:33:00+01:00","type":"bugfix","status":"ok","note":"Identity-only profiles are allowed to exist long enough to remember explicit pronoun corrections or preferences, even when a speaker has not yet built up rich broader interaction history with the bot."} {"ts":"2026-05-02T22:10:00+01:00","type":"architecture","status":"ok","note":"Pronoun inference belongs to the situational sidecar, not a parallel regex parser. The sidecar now treats the current prompt itself as valid context, can emit multiple explicit acceptable pronoun sets, and its evidence is threaded into both event summaries and durable profile state."} {"ts":"2026-05-02T22:16:00+01:00","type":"architecture","status":"ok","note":"Ollama sidecar calls are more reliable under actual JSON-schema structured outputs than bare JSON mode. The situational reader now uses schema-constrained `format` payloads with deterministic temperature and can carry room-read fields plus pronoun evidence in a single no-thinking pass."} +{"ts":"2026-05-02T21:52:56Z","type":"implementation","status":"ok","note":"Situational sidecar now emits transcript-wide Ghostlight-style participant reads with durable binary label families plus ephemeral situational state; roster-constrained schema and full configured Ollama timeout are needed to keep multi-person reads viable on a busy remote box."}