ChatAgent: dead restart-loop breaker + reset_turn_state + partial preservation

Đang mở
#42 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
65/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
elixir
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu với các vị trí được nêu trong chat_agent.ex, initializer.ex và state_machine.ex, lần theo summary/resume_from_summary và đường dẫn compaction của auto_restart_context. Kiểm tra cách pending_messages được khôi phục, cách replacement CLI được theo dõi và dừng lại, cũng như cách các lỗi compaction cập nhật status và ETS. Được xem là hoàn tất khi các message đang chờ trong hàng đợi vẫn tồn tại sau respawn và các lỗi compaction để lại một lỗi đã được lưu persistent với status hợp lệ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug reliability

Problem

Three smaller ChatAgent correctness gaps.

pending_sends lost on crash-respawn. summary/1 exposes the queue as pending_messages (chat_agent.ex:1655) and it survives into ETS + the agent log, but Initializer.resume_from_summary (initializer.ex:188) never maps it back — struct(Loopyard.ChatAgent, saved) ignores :pending_messages, so pending_sends resets to []. Messages queued while :thinking (the UI promised they'd "send when the agent finishes") silently vanish on GenServer crash → RestartController respawn. Contradicts the "inbox is Loopyard state, a restart doesn't lose messages" durability contract.

auto_restart_context spawns a CLI without track_os_pid. chat_agent.ex:833 — unlike every other spawn site, compaction's start_session never calls SessionManager.track_os_pid/1. tracked_cli_os_pid keeps pointing at the old stopped CLI; the new CLI is untracked and leaks as an orphan if the agent is later brutal-killed. Same site uses a raw linked Task.async for the stop (chat_agent.ex:821) instead of SessionManager.stop_backend.

:compacting status not in the StateMachine. chat_agent.ex:858 — if start_session fails after the :compacting flip, status never resets → UI shows "Compacting" indefinitely; the appended error message is never written to ETS (no :ets.insert) so it vanishes on refresh. :compacting is absent from StateMachine.@states/@transitions (state_machine.ex:49), so removing an agent mid-compaction logs a spurious "invalid transition" warning.

Fix

  • Map pending_messages back to pending_sends in resume_from_summary.
  • Call track_os_pid after auto_restart_context's start_session; use SessionManager.stop_backend for the stop.
  • Add :compacting to the StateMachine graph and reset status + persist the error message on the failure branch.

Acceptance

  • Queued messages survive a crash-respawn.
  • Compaction failure returns the agent to a real status and shows a persisted error.
Ngôn ngữ chính
Elixir
Star
85
Fork
11
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của loopyard/loopyard

Tất cả issue của loopyard/loopyard

Issue tương tự

Thêm issue về Elixir

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.