Skip to content

Commit 804ea30

Browse files
committed
refactor: decompose executeToolsIfNeeded into focused helper methods
Extract 14 helper methods from the monolithic executeToolsIfNeeded method to improve maintainability and reduce complexity: - getInitialResponse(): Get initial response from stream or cache - saveResponseToState(): Save response output to state - markStateComplete(): Mark conversation complete - saveToolResultsToState(): Save tool results to state - checkForInterruption(): Handle interruption signals - shouldStopExecution(): Evaluate stop conditions - hasExecutableToolCalls(): Check for executable tools - executeAutoApproveTools(): Execute non-approval tools - handleApprovalCheck(): Deduplicated approval workflow - executeToolRound(): Execute one round of tools - resolveAsyncFunctionsForTurn(): Resolve async params per turn - applyNextTurnParams(): Apply nextTurnParams - makeFollowupRequest(): Build and send follow-up requests - validateFinalResponse(): Validate final response The main method is reduced from ~400 lines to ~110 lines, acting as a clean coordinator that delegates to these focused helpers. Also replaces 'name as string' casts with String() for safer conversion.
1 parent 2c1d288 commit 804ea30

File tree

1 file changed

+381
-345
lines changed

1 file changed

+381
-345
lines changed

0 commit comments

Comments
 (0)