[chat] routes/chat_routes.py at 1110 lines exceeds AGENTS.md ~400 line limit #724
Labels
No labels
area:chat
area:core
area:llm
area:routes
area:tools
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sleepy/odysseus#724
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
routes/chat_routes.pyis 1110 lines — nearly 3× the AGENTS.md ~400 line limit.The file contains:
_active_streams,_stream_set)_session_url_matches_endpoint,_clear_orphaned_session_endpoint)setup_chat_routes()with all routes defined as closures/api/chat— non-streaming chat endpoint/api/chat_stream— streaming chat endpoint (~600 lines of nested generator logic)/api/chat/resume,/api/chat/stop,/api/chat/stream_status/api/inject_context/api/search— message search/api/rewrite— message rewriteThe
chat_streamendpoint alone has the streaming generator, research polling loop, chat mode streaming, agent mode streaming, image generation routing, error handling, and partial-save logic — all as nested closures.AGENTS.md violations
Suggested fix
Split into:
routes/chat/chat_stream.py— streaming chat endpoint + helpersroutes/chat/chat_sync.py— non-streaming/api/chatroutes/chat/chat_research.py— research integration within streamsroutes/chat/stream_state.py— active stream tracking, resume/stop/statusroutes/chat/chat_search.py— message search and rewriteroutes/chat_routes.pyas thin wiring that imports and registers