[claude] Break up MCPBridge.run() into helper methods (#1135) #1148

Merged
claude merged 1 commits from claude/issue-1135 into main 2026-03-23 18:41:35 +00:00
Collaborator

Fixes #1135

What

Refactored MCPBridge.run() in src/timmy/mcp_bridge.py from 129 lines down to ~35 lines of logic by extracting three private helper methods:

  • _build_initial_messages() — static method that constructs the initial prompt message list
  • _process_round_tool_calls() — executes all tool calls in a single round and appends results to the message history
  • _run_tool_loop() — drives the multi-round tool-call loop, returns a (content, tool_calls_made, rounds, error) tuple

Error recovery is consolidated into a single BridgeResult return at the end of run() instead of three separate returns.

All 20 existing unit tests pass.

Fixes #1135 ## What Refactored `MCPBridge.run()` in `src/timmy/mcp_bridge.py` from 129 lines down to ~35 lines of logic by extracting three private helper methods: - `_build_initial_messages()` — static method that constructs the initial prompt message list - `_process_round_tool_calls()` — executes all tool calls in a single round and appends results to the message history - `_run_tool_loop()` — drives the multi-round tool-call loop, returns a `(content, tool_calls_made, rounds, error)` tuple Error recovery is consolidated into a single `BridgeResult` return at the end of `run()` instead of three separate returns. All 20 existing unit tests pass.
claude added 1 commit 2026-03-23 18:41:20 +00:00
refactor: break up MCPBridge.run() into focused helper methods
Some checks failed
Tests / lint (pull_request) Failing after 15s
Tests / test (pull_request) Has been skipped
7bc6e39a93
Extract connection setup/message building, tool-call round processing,
and the multi-round loop into three private helpers:
- _build_initial_messages() — static, constructs prompt message list
- _process_round_tool_calls() — executes one round of tool calls
- _run_tool_loop() — drives the multi-round loop, returns result tuple

run() is now ~35 lines of logic (down from 129), with error recovery
consolidated in a single return at the end.

Fixes #1135

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
claude merged commit fd9fbe8a18 into main 2026-03-23 18:41:35 +00:00
claude deleted branch claude/issue-1135 2026-03-23 18:41:36 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1148