Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-date-hallucination.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bradygaster/squad-sdk': patch
---

Fix date hallucination in spawned agents by injecting current ISO timestamp into prompts. Replace hardcoded 2025 dates in scribe-charter templates with dynamic placeholders.
8 changes: 4 additions & 4 deletions packages/squad-cli/templates/scribe-charter.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ After every substantial work session:
│ ├── river-jwt-auth.md
│ └── kai-component-lib.md
├── orchestration-log/ # Per-spawn log entries
│ ├── 2025-07-01T10-00-river.md
│ └── 2025-07-01T10-00-kai.md
│ ├── {timestamp}-river.md
│ └── {timestamp}-kai.md
├── log/ # Session history — searchable record
│ ├── 2025-07-01-setup.md
│ └── 2025-07-02-api.md
│ ├── {date}-setup.md
│ └── {date}-api.md
Comment on lines 213 to +218
└── agents/
├── kai/history.md # Kai's personal knowledge
├── river/history.md # River's personal knowledge
Expand Down
5 changes: 5 additions & 0 deletions packages/squad-sdk/src/coordinator/fan-out.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { AgentCharter } from '../agents/index.js';
import type { EventBus } from '../client/event-bus.js';
import type { SessionPool } from '../client/session-pool.js';


// --- Spawn Configuration ---

export interface AgentSpawnConfig {
Expand Down Expand Up @@ -185,6 +186,10 @@ async function spawnSingle(
function buildInitialPrompt(config: AgentSpawnConfig): string {
const parts: string[] = [];

// Inject current date so spawned agents know the real date/time.
// Without this, LLMs hallucinate dates (especially the year).
parts.push(`**Current Date:** ${new Date().toISOString()}`);

if (config.priority && config.priority !== 'normal') {
parts.push(`**Priority:** ${config.priority.toUpperCase()}`);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/squad-sdk/templates/scribe-charter.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ After every substantial work session:
│ ├── river-jwt-auth.md
│ └── kai-component-lib.md
├── orchestration-log/ # Per-spawn log entries
│ ├── 2025-07-01T10-00-river.md
│ └── 2025-07-01T10-00-kai.md
│ ├── {timestamp}-river.md
│ └── {timestamp}-kai.md
├── log/ # Session history — searchable record
│ ├── 2025-07-01-setup.md
│ └── 2025-07-02-api.md
│ ├── {date}-setup.md
│ └── {date}-api.md
Comment on lines 213 to +218
└── agents/
├── kai/history.md # Kai's personal knowledge
├── river/history.md # River's personal knowledge
Expand Down
8 changes: 4 additions & 4 deletions templates/scribe-charter.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ After every substantial work session:
│ ├── river-jwt-auth.md
│ └── kai-component-lib.md
├── orchestration-log/ # Per-spawn log entries
│ ├── 2025-07-01T10-00-river.md
│ └── 2025-07-01T10-00-kai.md
│ ├── {timestamp}-river.md
│ └── {timestamp}-kai.md
├── log/ # Session history — searchable record
│ ├── 2025-07-01-setup.md
│ └── 2025-07-02-api.md
│ ├── {date}-setup.md
│ └── {date}-api.md
Comment on lines 213 to +218
└── agents/
├── kai/history.md # Kai's personal knowledge
├── river/history.md # River's personal knowledge
Expand Down
21 changes: 21 additions & 0 deletions test/fan-out.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,27 @@ describe('spawnParallel', () => {
expect(sentPrompt).toContain('Related to PRD-5');
});

it('should include current date in prompt', async () => {
const configs: AgentSpawnConfig[] = [
{ agentName: 'fenster', task: 'Build feature' },
];

const results = await spawnParallel(configs, mockDeps);

expect(results[0].status).toBe('success');

const createSessionMock = mockDeps.createSession as any;
const mockSession = await createSessionMock.mock.results[0].value;
const sentPrompt = mockSession.sendMessage.mock.calls[0][0].prompt;

// Prompt must contain a Current Date with ISO timestamp
expect(sentPrompt).toContain('**Current Date:**');
const dateMatch = sentPrompt.match(/\*\*Current Date:\*\*\s*(\S+)/);
expect(dateMatch).not.toBeNull();
const timestamp = dateMatch![1];
expect(timestamp).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/);
Comment on lines +136 to +141
});

it('should handle model overrides', async () => {
const configs: AgentSpawnConfig[] = [
{
Expand Down
Loading