openclaw-vainplex/src/config
hsrvc 8da4f259dd Implement Phase 2: Topic-level message history isolation for multi-topic Telegram support
Add topic-specific session file isolation to fix root cause of Gemini turn validation errors.
Each Telegram topic now maintains its own conversation history file, eliminating race
conditions and message corruption during concurrent topic processing.

Changes:
1. Enhanced resolveSessionTranscriptPath() to support optional topicId parameter
   - Topic ID (Telegram messageThreadId) now incorporated into session filename
   - Format: sessionId.jsonl (direct chats) vs sessionId-topic-{topicId}.jsonl (topics)
   - Backward compatible: topicId is optional

2. Updated reply.ts to pass MessageThreadId to session file resolution
   - ctx.MessageThreadId now flows through to resolveSessionTranscriptPath()
   - Automatically provides topic context for each incoming message

3. Automatic propagation through entire system
   - sessionFile parameter automatically carries topic-specific path through:
     - FollowupRun object (queued runs)
     - runEmbeddedPiAgent() calls
     - compactEmbeddedPiSession() calls
     - SessionManager lifecycle (load, read, write operations)

Benefits:
✓ Complete elimination of shared .jsonl race conditions
✓ Each topic's conversation history independently cached
✓ SessionManager instances operate on isolated files
✓ No concurrent mutations of the same message history
✓ Maintains full Phase 1 turn validation as safety layer

Testing:
✓ Build succeeds with no TypeScript errors
✓ Backward compatible with non-topic sessions (direct messages)
✓ Topic ID properly extracted from Telegram messageThreadId

Expected impact:
- Gemini "function call turn" errors eliminated (root cause fixed)
- Message history corruption prevented across all topics
- Improved stability in multi-topic scenarios
- Each topic maintains independent conversation state

This completes the two-phase fix:
- Phase 1 (previous): Turn validation to suppress errors
- Phase 2 (current): Topic isolation to fix root cause

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-07 22:51:26 +00:00
..
config.test.ts feat: telegram draft streaming 2026-01-07 11:08:32 +01:00
config.ts chore: rename project to clawdbot 2026-01-04 14:38:51 +00:00
defaults.ts chore: fix lint warnings 2026-01-06 05:41:24 +01:00
group-policy.ts feat: multi-agent routing + multi-account providers 2026-01-06 18:33:37 +00:00
io.ts feat: add ack reaction defaults 2026-01-06 03:28:47 +00:00
legacy-migrate.ts chore: rename project to clawdbot 2026-01-04 14:38:51 +00:00
legacy.ts fix: clean model config typing 2026-01-06 01:08:36 +00:00
model-alias-defaults.test.ts feat!: redesign model config + auth profiles 2026-01-06 00:56:58 +00:00
paths.test.ts fix(oauth): derive oauth.json from state dir 2026-01-04 19:08:13 +01:00
paths.ts feat!: redesign model config + auth profiles 2026-01-06 00:56:58 +00:00
port-defaults.ts feat: add --dev/--profile CLI profiles 2026-01-05 01:27:13 +01:00
schema.test.ts feat: unify onboarding + config schema 2026-01-03 16:48:08 +01:00
schema.ts fix: suppress whatsapp pairing in self-phone mode 2026-01-07 20:49:58 +01:00
sessions.cache.test.ts Optimize multi-topic performance with TTL-based session caching 2026-01-07 22:51:26 +00:00
sessions.test.ts feat: multi-agent routing + multi-account providers 2026-01-06 18:33:37 +00:00
sessions.ts Implement Phase 2: Topic-level message history isolation for multi-topic Telegram support 2026-01-07 22:51:26 +00:00
talk.ts refactor: split config module 2026-01-04 07:05:17 +01:00
types.ts Optimize multi-topic performance with TTL-based session caching 2026-01-07 22:51:26 +00:00
ui-seam-color.test.ts feat: add ui.seamColor accent 2025-12-30 04:14:36 +01:00
validation.ts feat!: redesign model config + auth profiles 2026-01-06 00:56:58 +00:00
zod-schema.ts refactor: centralize typing mode signals 2026-01-07 22:18:11 +00:00