xonecas.io
5875
Os

ollama-space-molt-player / commit f58d236

refactor: generate memory summary dynamically in mock-prompt script

xonecas2026-02-01 f58d2360d52339c4b3e890d2315d258886d107c5 parent 92b0d86

1 file changed

scripts/mock-prompt.ts+50−24
@@ -3,7 +3,12 @@
33
44 import type { ClientState } from "../client/src/client";
55 import type { HistoryEntry } from "../src/memory";
6-import { buildActionPrompt, type WorldSnapshot } from "../src/prompt";
6+import { OllamaAgent } from "../src/ollama";
7+import {
8+ buildActionPrompt,
9+ buildSummaryPrompt,
10+ type WorldSnapshot,
11+} from "../src/prompt";
712 import type {
813 AlignmentType,
914 PersonalityType,
@@ -270,30 +275,51 @@ const mockForumFollowUpStatus: "unread" | "periodic" | null = "periodic";
270275
271276 // Mock repetition warning (null = no warning)
272277 const mockRepetitionWarning: { action: string; count: number } | null = null;
273-const mockMemorySummary =
274- "Recently traveled to the asteroid belt and mined resources while staying alert for nearby activity.";
275278 const mockLastActionResult =
276279 "Action: 2025-01-01T00:00:00.000Z mine\nResult:\n- Mined 5x iron_ore";
277280
278-// Build the prompt exactly as we would in production
279-const prompt = buildActionPrompt({
280- state: mockClientState,
281- worldSnapshot: mockWorldSnapshot,
282- recentHistory: mockRecentHistory,
283- memorySummary: mockMemorySummary,
284- lastActionResult: mockLastActionResult,
285- currentGoal:
286- "Map the Sol Prime system and gather resources for the journey to Alpha Centauri",
287- empire: mockPlayer.empire,
288- alignment: mockAlignment,
289- personality: mockPersonality,
290- speechStyle: mockSpeechStyle,
291- lastForumThreadId: mockLastForumThreadId,
292- lastForumPostTitle: mockLastForumPostTitle,
293- lastForumPostCategory: mockLastForumPostCategory,
294- forumFollowUpStatus: mockForumFollowUpStatus,
295- repetitionWarning: mockRepetitionWarning,
296-});
281+// Create Ollama client for generating memory summary
282+const ollama = new OllamaAgent(
283+ process.env.OLLAMA_URL ?? "http://localhost:11434",
284+ process.env.OLLAMA_MODEL ?? "qwen3:8b",
285+ 60000, // timeout
286+ 0.1, // temperature for summary (lower for deterministic output)
287+ false, // no thinking for summary
288+);
297289
298-// Output verbatim
299-console.log(prompt);
290+async function main() {
291+ // Generate memory summary via Ollama (just like production)
292+ let memorySummary = "(summary unavailable)";
293+ try {
294+ const summaryPrompt = buildSummaryPrompt(mockRecentHistory);
295+ const summaryText = await ollama.generateText(summaryPrompt);
296+ memorySummary = summaryText || "(summary unavailable)";
297+ } catch (error) {
298+ console.error("Error generating summary:", (error as Error).message);
299+ }
300+
301+ // Build the prompt exactly as we would in production
302+ const prompt = buildActionPrompt({
303+ state: mockClientState,
304+ worldSnapshot: mockWorldSnapshot,
305+ recentHistory: mockRecentHistory,
306+ memorySummary,
307+ lastActionResult: mockLastActionResult,
308+ currentGoal:
309+ "Map the Sol Prime system and gather resources for the journey to Alpha Centauri",
310+ empire: mockPlayer.empire,
311+ alignment: mockAlignment,
312+ personality: mockPersonality,
313+ speechStyle: mockSpeechStyle,
314+ lastForumThreadId: mockLastForumThreadId,
315+ lastForumPostTitle: mockLastForumPostTitle,
316+ lastForumPostCategory: mockLastForumPostCategory,
317+ forumFollowUpStatus: mockForumFollowUpStatus,
318+ repetitionWarning: mockRepetitionWarning,
319+ });
320+
321+ // Output verbatim
322+ console.log(prompt);
323+}
324+
325+main();