Skip to content

bug: async chat with save_to_session completes but never creates a chat session #1444

Description

@vybe

Summary

Async-mode chat (dynamic-thinking / fire-and-forget submission) with save_to_session=true completes the execution successfully but never creates a chat session — the conversation is silently lost instead of being persisted.

Context

Caught by two consecutive full-suite runs (2026-07-03, 2026-07-04):

  • tests/test_dynamic_thinking_status.py::TestAsyncModeSessionPersistence::test_async_mode_with_save_to_session (tests/test_dynamic_thinking_status.py:455) — 0 sessions found before AND after the async turn
  • ::test_async_mode_session_contains_messages (tests/test_dynamic_thinking_status.py:514) — same

Environment cascade is ruled out: in the 2026-07-04 run the sibling async tests in the same module passed (test_async_mode_returns_accepted, test_async_mode_execution_id_is_pollable, test_async_mode_completes_eventually, test_sse_stream_available_during_execution) — so the async execution path itself worked while session persistence did not.

Acceptance Criteria

  • An async-mode chat with save_to_session=true creates a chat_sessions row and persists both user and assistant messages once the execution completes
  • Both TestAsyncModeSessionPersistence tests pass in the integration suite
  • Root cause documented (was persistence skipped on the async completion path, or does session creation race the 202 return?)

Technical Notes

  • save_to_session is handled in src/backend/routers/chat.py (model in src/backend/models.py)
  • Suspect the async completion path finalizes the execution without running the session-persistence step the sync path runs — check where the sync path writes chat_sessions/chat_messages vs what the async terminal applier does

Activity

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions