[agent_loop.py] 2158-line god file must be split per AGENTS.md ~400 line limit #664
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#664
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?
File:
src/agent_loop.py(2158 lines)AGENTS.md rule: "Split files that exceed ~400 lines or contain multiple concerns."
This file contains at least 6 distinct concerns:
_AGENT_PREAMBLE,_AGENT_RULES,_API_AGENT_RULES,TOOL_SECTIONS,_assemble_prompt,_build_base_prompt,_build_system_prompt) — ~500 lines of prompt templates + assembly logic_detect_admin_intent,_recent_context_for_retrieval,_extract_last_user_message, tool-index integration) — mixed intostream_agent_loopstream_agent_loop) — ~900 lines of the main loop_run_verifier_subagent,_build_actions_snapshot,_VERIFIER_*) — ~80 lines_compute_final_metrics) — ~50 linesSuggested split
src/agent/prompts.py— system prompt templates + assemblysrc/agent/tool_selection.py— admin detection, RAG retrieval, keyword fallbacksrc/agent/streaming.py— the corestream_agent_loop(consumes the above)src/agent/verifier.py— completion verifiersrc/agent/metrics.py— metrics computationsrc/agent/doc_streaming.py— document content streaming helpersEach sub-module should be imported through a narrow interface. The existing
agent_tools.pyfacade pattern is a good model.