Skip to content

feat: history truncation + lazy message rehydrate (daemon + IPC)#9295

Merged
ashleeradka merged 1 commit into
mainfrom
swarm/text-retention-fix/task-1
Feb 26, 2026
Merged

feat: history truncation + lazy message rehydrate (daemon + IPC)#9295
ashleeradka merged 1 commit into
mainfrom
swarm/text-retention-fix/task-1

Conversation

@ashleeradka
Copy link
Copy Markdown
Contributor

@ashleeradka ashleeradka commented Feb 26, 2026

Summary

Add server-side text and tool result truncation to history responses, plus a new message_content_request endpoint for on-demand full-content retrieval. This is the daemon/IPC foundation for client-side memory optimization — clients can now request lightweight history (truncated text, no heavy payloads) and fetch full content only when needed.

Implementation

IPC Contract Changes (ipc-contract/sessions.ts)

  • HistoryRequest: Added maxTextChars and maxToolResultChars optional fields for server-side truncation
  • New MessageContentRequest / MessageContentResponse message types for single-message full-content fetch
  • HistoryResponse messages: Added wasTruncated boolean flag

Server Handler (handlers/sessions.ts)

  • handleHistoryRequest: Applies text truncation (maxTextChars) and tool result truncation (maxToolResultChars) with … [truncated] suffix. Sets wasTruncated: true on affected messages.
  • New handleMessageContentRequest: Fetches a single message by ID from the conversation store, parses and renders its content (text + tool calls), returns full untruncated data.

Data Layer (conversation-store.ts)

  • Added getMessageById(messageId, conversationId?) for efficient single-message lookup.

Generated Types (IPCContractGenerated.swift)

  • Auto-generated Swift types for all new IPC fields: IPCMessageContentRequest, IPCMessageContentResponse, IPCMessageContentResponseToolCall, plus updated IPCHistoryRequest and IPCHistoryResponseMessage.

Files Changed

  • assistant/src/daemon/ipc-contract/sessions.ts — contract extensions
  • assistant/src/daemon/handlers/sessions.ts — truncation logic + new handler
  • assistant/src/memory/conversation-store.tsgetMessageById
  • assistant/src/daemon/ipc-contract-inventory.json — new message types
  • assistant/src/__tests__/ipc-snapshot.test.ts — test fixtures
  • assistant/src/__tests__/__snapshots__/ipc-snapshot.test.ts.snap — updated snapshots
  • clients/shared/IPC/Generated/IPCContractGenerated.swift — regenerated Swift types

Testing

  • IPC snapshot tests updated with fixtures for new message types
  • Manual: send history_request with maxTextChars: 100 → verify truncated text with wasTruncated: true
  • Manual: send message_content_request for a truncated message → verify full content returned

Context

Part of the text-retention-fix blitz (epic #9272). M1 of 5 milestones.
Closes #9273

🤖 Generated with Claude Code


Open with Devin

Co-Authored-By: Claude <noreply@anthropic.com>
@ashleeradka ashleeradka self-assigned this Feb 26, 2026
@ashleeradka ashleeradka merged commit 2fcb254 into main Feb 26, 2026
5 of 7 checks passed
@ashleeradka ashleeradka deleted the swarm/text-retention-fix/task-1 branch February 26, 2026 00:59
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review

Comment thread assistant/src/daemon/handlers/sessions.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 96701cd10c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread assistant/src/daemon/handlers/sessions.ts
Comment thread assistant/src/daemon/handlers/sessions.ts
@ashleeradka
Copy link
Copy Markdown
Contributor Author

Addressed in #9315

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

M1: History truncation + lazy rehydrate (daemon + IPC)

1 participant