Skip to content

refactor: extract executeConversationTurn() helper and fix transient timing#219

Merged
chubes4 merged 1 commit into
Extra-Chill:mainfrom
saraichinwag:fix/211-extract-conversation-turn
Feb 17, 2026
Merged

refactor: extract executeConversationTurn() helper and fix transient timing#219
chubes4 merged 1 commit into
Extra-Chill:mainfrom
saraichinwag:fix/211-extract-conversation-turn

Conversation

@saraichinwag
Copy link
Copy Markdown
Contributor

Summary

Extracts a shared executeConversationTurn() private method from the three chat endpoints (handle_chat, handle_continue, handle_ping), eliminating ~200 lines of duplicated AI loop + error handling + AgentContext management code.

Transient Timing Fix

Moves the X-Request-ID transient cache set to before the AI loop executes (right after session creation), preventing duplicate sessions when retries arrive during processing.

Changes

  • Added: executeConversationTurn() - encapsulates AgentContext set/clear, ToolManager, AIConversationLoop execution, error handling, and session error updates
  • Refactored: handle_chat(), handle_continue(), handle_ping() to use the shared helper
  • Fixed: Transient set timing in handle_chat() - now set immediately after session resolution, before AI loop

What's Unchanged

  • All public API contracts (request/response shapes)
  • Route registration and permission callbacks
  • verify_ping_token, list_sessions, delete_session, get_session
  • Pending session deduplication logic in handle_chat

Fixes #211
Fixes #5

@chubes4 chubes4 merged commit 2dfbcfb into Extra-Chill:main Feb 17, 2026
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.

Chat: Extract shared executeConversationTurn() helper + fix transient timing Chat request duplication/splitting during slow responses

2 participants