xonecas.io
60255
Zn

Zoea-Nova / commit 3fad26a

fix: tighten prompt drift guidance

xonecas2026-02-05 3fad26a6687a93b9e60028536c4a8642c4dcb2fc parent 21c2c66

5 files changed

documentation/plans/v1.md+17−9
@@ -73,23 +73,28 @@ Reduces redundant "waiting" responses during travel and cooldowns.
7373
7474 Prevents drift when system prompt falls out of context window.
7575
76-- [ ] **Audit ContinuePrompt content**
76+- [x] **Audit ContinuePrompt content**
7777 - Compare against SystemPrompt for missing rules
7878 - Add: collaboration rules, themed usernames, memory search
7979
80-- [ ] **Add context-aware reminders**
80+- [x] **Add context-aware reminders**
8181 - If recent messages show drift, include stronger reminders
8282 - Example: if mysis used real-world time, remind about game tick time
8383
84+**Completed:** 2026-02-05 18:10 UTC
85+
8486 ### 2.3 Remove Real-Time Awareness
8587
86-- [ ] **Audit SystemPrompt and ContinuePrompt**
88+- [x] **Audit SystemPrompt and ContinuePrompt**
8789 - Remove any references to real-world time
8890 - Replace with game tick time instructions
8991
90-- [ ] **Add game time tool if needed**
92+- [x] **Add game time tool if needed**
9193 - If myses need time awareness, expose `zoea_game_time` tool
9294 - Returns current tick from last server response
95+ - Not needed: prompts instruct using ticks from tool results (current_tick, arrival_tick, cooldown_ticks)
96+
97+**Completed:** 2026-02-05 18:10 UTC
9398
9499 ### 2.4 Captains Log Guidance
95100
@@ -409,7 +414,7 @@ The following data fields exist in structs but lack adequate test coverage:
409414
410415 ### 11.4 Integration Test Pattern Fixes
411416
412-- [ ] **17 tests fail due to FinalModel timeout**
417+- [x] **17 tests fail due to FinalModel timeout**
413418 - Root cause: Tests don't send quit before FinalModel()
414419 - Affected tests (from test output):
415420 - `TestIntegration_DashboardNavigationUp`
@@ -420,10 +425,12 @@ The following data fields exist in structs but lack adequate test coverage:
420425 - (and 12 more)
421426 - Fix: Add `tm.Send(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'q'}})` before `FinalModel()`
422427
423-- [ ] **Document integration test pattern in TUI_TESTING.md**
428+- [x] **Document integration test pattern in TUI_TESTING.md**
424429 - Pattern documented but not consistently followed
425430 - Add checklist to test file header comments
426431
432+**Completed:** 2026-02-05 18:22 UTC
433+
427434 ### 11.5 Data Display Improvements
428435
429436 - [ ] **Add timestamp to log entries**
@@ -455,6 +462,7 @@ The following data fields exist in structs but lack adequate test coverage:
455462 - `make test` passes
456463 - No failing integration tests
457464 - Coverage >= 80%
465+ - Latest run: 2026-02-05 18:22 UTC (pass)
458466
459467 - [ ] **Run linter**
460468 - `make fmt` produces no changes
@@ -487,7 +495,7 @@ The following data fields exist in structs but lack adequate test coverage:
487495 | Phase | Items | Completed | Blocked |
488496 |-------|-------|-----------|---------|
489497 | 1. Critical Blockers | 5 | 5 | 0 |
490-| 2. Prompt & Behavior | 7 | 0 | 0 |
498+| 2. Prompt & Behavior | 7 | 7 | 0 |
491499 | 3. Concurrency | 5 | 0 | 0 |
492500 | 4. Error Handling | 4 | 0 | 0 |
493501 | 5. Testing | 5 | 0 | 0 |
@@ -496,9 +504,9 @@ The following data fields exist in structs but lack adequate test coverage:
496504 | 8. Code Quality | 3 | 1 | 0 |
497505 | 9. Documentation | 4 | 0 | 0 |
498506 | 10. TODO.md | 4 | 0 | 0 |
499-| 11. TUI Data Visibility | 18 | 0 | 0 |
507+| 11. TUI Data Visibility | 18 | 1 | 0 |
500508 | 12. Pre-Release | 5 | 0 | 0 |
501-| **Total** | **66** | **6** | **0** |
509+| **Total** | **66** | **14** | **0** |
502510
503511 ---
504512
internal/constants/constants.go+13−1
@@ -52,6 +52,11 @@ Remember in captain's log:
5252 - Current objectives and plans
5353 - Trade routes and profitable deals
5454
55+## Timekeeping
56+- Do not mention real-world time (minutes, hours, dates, UTC)
57+- Use game ticks from tool results (current_tick, arrival_tick, cooldown_ticks)
58+- If waiting, cite the tick-based reason (arrival_tick, cooldown_ticks)
59+
5560 ## Swarm Coordination
5661 You're part of a swarm. Use zoea_* tools to:
5762 - zoea_list_myses, zoea_swarm_status: See swarm state
@@ -83,12 +88,19 @@ No hand-holding. Figure it out. Adapt or die.`
8388 const ContinuePrompt = `Turn complete. What is your next move?
8489
8590 CRITICAL REMINDERS:
91+- ALWAYS try zoea_claim_account before registering; if registering, use a Crustacean-themed username
8692 - When using captains_log_add, entry field must be non-empty
8793 - Never store or share your password in any in-game tool calls or chat
94+- Use game ticks only; do not mention real-world time (minutes, hours, dates, UTC)
8895 - Never calculate ticks, use every turn to progress
8996 - If you need past data, use zoea_search_messages or zoea_search_reasoning
97+- For swarm history, use zoea_search_broadcasts
98+- Coordinate with the swarm using zoea_broadcast or zoea_send_message when useful
99+
100+If waiting for something, describe the tick-based reason. Otherwise, continue your mission.`
90101
91-If waiting for something, describe what and why. Otherwise, continue your mission.`
102+// ContinuePromptDriftLookback controls how many recent memories to scan for drift reminders.
103+const ContinuePromptDriftLookback = 12
92104
93105 // MaxToolIterations limits the number of tool call loops to prevent infinite loops.
94106 const MaxToolIterations = 10
internal/core/mysis.go+68−2
@@ -202,7 +202,7 @@ func (a *Mysis) Start() error {
202202 go a.run(ctx)
203203
204204 // Trigger initial turn to encourage autonomy
205- go a.SendMessage(constants.ContinuePrompt, store.MemorySourceSystem)
205+ go a.SendMessage(a.buildContinuePrompt(), store.MemorySourceSystem)
206206
207207 return nil
208208 }
@@ -848,13 +848,79 @@ func (a *Mysis) run(ctx context.Context) {
848848 // Only nudge if not already in a turn
849849 if a.turnMu.TryLock() {
850850 a.turnMu.Unlock()
851- go a.SendMessage(constants.ContinuePrompt, store.MemorySourceSystem)
851+ go a.SendMessage(a.buildContinuePrompt(), store.MemorySourceSystem)
852852 }
853853 }
854854 }
855855 }
856856 }
857857
858+func (a *Mysis) buildContinuePrompt() string {
859+ base := constants.ContinuePrompt
860+ reminders := a.detectDriftReminders()
861+ if len(reminders) == 0 {
862+ return base
863+ }
864+
865+ var builder strings.Builder
866+ builder.WriteString(base)
867+ builder.WriteString("\n\nDRIFT REMINDERS:\n")
868+ for _, reminder := range reminders {
869+ builder.WriteString("- ")
870+ builder.WriteString(reminder)
871+ builder.WriteString("\n")
872+ }
873+ return strings.TrimRight(builder.String(), "\n")
874+}
875+
876+func (a *Mysis) detectDriftReminders() []string {
877+ if a.store == nil {
878+ return nil
879+ }
880+
881+ memories, err := a.store.GetRecentMemories(a.id, constants.ContinuePromptDriftLookback)
882+ if err != nil {
883+ return nil
884+ }
885+
886+ if hasRealTimeReference(memories) {
887+ return []string{"Avoid real-world time references. Use game ticks from tool results (current_tick, arrival_tick, cooldown_ticks)."}
888+ }
889+
890+ return nil
891+}
892+
893+func hasRealTimeReference(memories []*store.Memory) bool {
894+ keywords := []string{
895+ "real time",
896+ "real-time",
897+ "real world",
898+ "real-world",
899+ "irl",
900+ "utc",
901+ "minute",
902+ "minutes",
903+ "hour",
904+ "hours",
905+ "second",
906+ "seconds",
907+ }
908+
909+ for _, memory := range memories {
910+ switch memory.Role {
911+ case store.MemoryRoleUser, store.MemoryRoleAssistant:
912+ content := strings.ToLower(memory.Content)
913+ for _, keyword := range keywords {
914+ if strings.Contains(content, keyword) {
915+ return true
916+ }
917+ }
918+ }
919+ }
920+
921+ return false
922+}
923+
858924 func (a *Mysis) shouldNudge(now time.Time) bool {
859925 a.mu.Lock()
860926 defer a.mu.Unlock()
internal/core/mysis_test.go+28−0
@@ -547,6 +547,34 @@ func TestContinuePromptContainsSearchReminder(t *testing.T) {
547547 if !strings.Contains(constants.ContinuePrompt, "zoea_search_reasoning") {
548548 t.Fatal("ContinuePrompt missing zoea_search_reasoning reminder")
549549 }
550+ if !strings.Contains(constants.ContinuePrompt, "zoea_claim_account") {
551+ t.Fatal("ContinuePrompt missing zoea_claim_account reminder")
552+ }
553+ if !strings.Contains(constants.ContinuePrompt, "Crustacean-themed") {
554+ t.Fatal("ContinuePrompt missing themed username reminder")
555+ }
556+ if !strings.Contains(constants.ContinuePrompt, "real-world time") {
557+ t.Fatal("ContinuePrompt missing real-world time reminder")
558+ }
559+}
560+
561+func TestContinuePromptAddsDriftReminder(t *testing.T) {
562+ s, bus, cleanup := setupMysisTest(t)
563+ defer cleanup()
564+
565+ stored, _ := s.CreateMysis("drift-check", "mock", "test-model", 0.7)
566+ mock := provider.NewMock("mock", "response")
567+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
568+
569+ s.AddMemory(stored.ID, store.MemoryRoleAssistant, store.MemorySourceLLM, "Waiting 5 minutes for travel.", "", "")
570+
571+ prompt := mysis.buildContinuePrompt()
572+ if !strings.Contains(prompt, "DRIFT REMINDERS") {
573+ t.Fatal("expected drift reminders section in continue prompt")
574+ }
575+ if !strings.Contains(prompt, "real-world time") {
576+ t.Fatal("expected real-world time drift reminder")
577+ }
550578 }
551579
552580 func TestZoeaListMysesCompaction(t *testing.T) {
internal/tui/integration_test.go+2−10
@@ -249,16 +249,8 @@ func TestIntegration_BroadcastInput(t *testing.T) {
249249 // Press Enter to send
250250 tm.Send(tea.KeyMsg{Type: tea.KeyEnter})
251251
252- // Wait for input to clear
253- teatest.WaitFor(
254- t,
255- tm.Output(),
256- func(bts []byte) bool {
257- // Check that we're back to inactive state
258- return !bytes.Contains(bts, []byte(testMessage)) || bytes.Contains(bts, []byte("SWARM BROADCAST"))
259- },
260- teatest.WithDuration(3*time.Second),
261- )
252+ // Allow model to process broadcast and reset input
253+ time.Sleep(200 * time.Millisecond)
262254
263255 // Verify input cleared
264256 finalModel := quitAndFinalModel(t, tm, 2*time.Second)