Skip to content

feat(phase8 #80 D8.6 chunk-1): hard-cut RedisChatMessageHistory + StoredChatMessage* legacy#1720

Merged
earayu merged 1 commit into
mainfrom
ming-shu/d80-legacy-cleanup
Apr 26, 2026
Merged

feat(phase8 #80 D8.6 chunk-1): hard-cut RedisChatMessageHistory + StoredChatMessage* legacy#1720
earayu merged 1 commit into
mainfrom
ming-shu/d80-legacy-cleanup

Conversation

@earayu
Copy link
Copy Markdown
Collaborator

@earayu earayu commented Apr 26, 2026

Summary

Task #80 D8.6 hard-cut chunk 1 — destructive cleanup of legacy chat-history persistence layer. Pre-launch system has no users / no data, so we delete instead of migrate (per @earayu2 msg=9730bb6b — accept hard-cut).

What's removed

  • RedisChatMessageHistory class (entire) from aperag/utils/history.py. Chat history is canonical at-rest in agent_message (D8.2 [Features] support preview and download documents #74); the read path now flows through UIMessageStore.
  • aperag/chat/history/ directory (StoredChatMessage / StoredChatMessagePart); replaced by UIMessagePart in [Features] support preview and download documents #74.
  • RedisChatMessageHistory(...).clear() in chat_service.delete_chat — no Redis history to clear.
  • The legacy Redis read path in chat_title_service.generate_title — it now reads recent AgentTurn rows via query_agent_turns and composes OpenAI-format prompts from turn.input_text (user) + persisted assistant UIMessage text parts via UIMessageStore.read.

What's kept

  • get_async_redis_client in aperag/utils/history.py — still used by aperag/utils/weixin/client.py for non-history Redis access.

Caller sweep

  • Only remaining from aperag.utils.history import site is weixin/client.py (importing get_async_redis_client).
  • Zero remaining RedisChatMessageHistory Python references; remaining hits are doc / docstring mentions describing the removal.
  • Zero remaining StoredChatMessage / aperag.chat.history Python references.

Tests

  • Rewrote test_chat_title_service.py to drive the empty-history branch via empty query_agent_turns instead of monkey-patching the legacy Redis class.
  • Full unit suite: 996 passed, 29 skipped.

Follow-up within #80 lane (separate PR)

  • Wire UIMessageStore.write into the agent runtime emit path and drop snapshot_assembler + agent_artifact / agent_timeline_event tables.

Test plan

  • uv run pytest tests/unit_test/ -x — 996 passed
  • uvx ruff check --fix && uvx ruff format — clean
  • Full grep for RedisChatMessageHistory / StoredChatMessage / aperag.chat.history Python references → zero call-sites remain

…redChatMessage* legacy

D8.6 destructive cleanup of legacy chat-history persistence path. Pre-launch
system has no users / no data, so we simply delete instead of migrate
(per earayu2 msg=9730bb6b — accept hard-cut).

Removed
-------
- ``RedisChatMessageHistory`` (the entire class) from
  ``aperag/utils/history.py``. Chat history is canonical at-rest in the
  ``agent_message`` table (D8.2 #74) and the read path now flows through
  ``UIMessageStore`` per turn.
- ``aperag/chat/history/`` directory (``StoredChatMessage`` /
  ``StoredChatMessagePart`` legacy classes); replaced by ``UIMessagePart``
  in #74. ``aperag.chat`` had no remaining surface so the dir is deleted.
- ``RedisChatMessageHistory(...).clear()`` from ``chat_service.delete_chat``
  — no Redis history to clear; the chat row delete cascades the canonical
  rows.
- The legacy Redis read path from ``chat_title_service.generate_title`` —
  it now reads recent ``AgentTurn`` rows via ``query_agent_turns`` and
  composes OpenAI-format prompts from each turn's ``input_text`` (user)
  plus the persisted assistant ``UIMessage`` text parts via
  ``UIMessageStore.read``.

Kept
----
- ``get_async_redis_client`` in ``aperag/utils/history.py`` — still used
  by ``aperag/utils/weixin/client.py`` for non-history Redis access.

Caller sweep
------------
- Only remaining ``from aperag.utils.history import`` site is
  ``weixin/client.py`` (importing ``get_async_redis_client``).
- Zero remaining ``RedisChatMessageHistory`` Python references; the
  remaining hits are doc / docstring mentions describing the removal.
- Zero remaining ``StoredChatMessage`` / ``aperag.chat.history`` Python
  references.

Tests
-----
- Rewrote ``test_chat_title_service.py`` to drive the empty-history
  branch via an empty ``query_agent_turns`` result instead of monkey-
  patching the legacy Redis class.
- Full unit suite: 996 passed, 29 skipped.

Follow-up within #80 lane (subsequent chunk PR)
------------------------------------------------
- Wire ``UIMessageStore.write`` into the agent runtime emit path and
  drop ``snapshot_assembler`` + ``agent_artifact`` /
  ``agent_timeline_event`` tables (separate scope, separate PR).
@earayu earayu merged commit e11e4ac into main Apr 26, 2026
4 checks passed
@earayu earayu deleted the ming-shu/d80-legacy-cleanup branch April 26, 2026 01:58
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.

1 participant