[loop-generated] [refactor] Break up oversized functions (100+ lines) #151

Closed
opened 2026-03-15 14:27:12 +00:00 by hermes · 0 comments
Collaborator

Problem

Several functions exceed 100 lines, making them hard to test, debug, and maintain:

Function File Lines
run_agentic_loop() src/timmy/agentic_loop.py 215
get_all_available_tools() src/timmy/tools.py 157
create_full_toolkit() src/timmy/tools.py 141
capture_error() src/infrastructure/error_capture.py 141
create_timmy() src/timmy/agent.py 126
lifespan() src/dashboard/app.py 122
complete() src/infrastructure/router/cascade.py 121
_maybe_distill() src/timmy/thinking.py 109
think_once() src/timmy/thinking.py 103
get_memory_status() src/timmy/tools_intro/__init__.py 98

tools.py alone is 879 lines.

Proposed fix

Extract logical sub-steps into named helper functions. Each function should do one thing. Target max 50 lines per function where practical.

Prioritize tools.py — the two 140+ line functions are just building dict/list structures that could be split by category.

Impact

  • Easier to test individual behaviors
  • Easier to read and review
  • Lines removed >= lines added (extract, don't duplicate)
## Problem Several functions exceed 100 lines, making them hard to test, debug, and maintain: | Function | File | Lines | |---|---|---| | `run_agentic_loop()` | `src/timmy/agentic_loop.py` | 215 | | `get_all_available_tools()` | `src/timmy/tools.py` | 157 | | `create_full_toolkit()` | `src/timmy/tools.py` | 141 | | `capture_error()` | `src/infrastructure/error_capture.py` | 141 | | `create_timmy()` | `src/timmy/agent.py` | 126 | | `lifespan()` | `src/dashboard/app.py` | 122 | | `complete()` | `src/infrastructure/router/cascade.py` | 121 | | `_maybe_distill()` | `src/timmy/thinking.py` | 109 | | `think_once()` | `src/timmy/thinking.py` | 103 | | `get_memory_status()` | `src/timmy/tools_intro/__init__.py` | 98 | `tools.py` alone is 879 lines. ## Proposed fix Extract logical sub-steps into named helper functions. Each function should do one thing. Target max 50 lines per function where practical. Prioritize `tools.py` — the two 140+ line functions are just building dict/list structures that could be split by category. ## Impact - Easier to test individual behaviors - Easier to read and review - Lines removed >= lines added (extract, don't duplicate)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#151