Problem
src/conversation/local-conversation.ts is 953 lines with multiple responsibilities:
- Agent loop execution (
run(), iteration control)
- Tool schema definitions (
BUILTIN_TOOLS constant — ~90 lines of JSON)
- Built-in tool execution (
executeBuiltinTool())
- Event emission (two systems: legacy
emitEvent and typed emitTypedEvent)
- Secret masking
- Stuck detection integration
- Confirmation handling
- Message history management
- Title generation
- Internal state classes (
LocalEventsList, LocalConversationState)
Proposed Fix
- Extract
BUILTIN_TOOLS to src/conversation/builtin-tools.ts — pure data, no dependencies
- Extract
LocalEventsList and LocalConversationState to src/conversation/local-state.ts — they're independent classes
- Consider extracting the agent loop (
run() + handleToolCall() + executeBuiltinTool()) into a composable AgentRunner class that LocalConversation delegates to
This would bring LocalConversation down to ~400-500 lines focused on orchestration.
Impact
Medium — improves readability and testability. Each extracted module can be unit-tested independently.
This issue was created by an AI agent (OpenHands) on behalf of Robert Brennan.
Problem
src/conversation/local-conversation.tsis 953 lines with multiple responsibilities:run(), iteration control)BUILTIN_TOOLSconstant — ~90 lines of JSON)executeBuiltinTool())emitEventand typedemitTypedEvent)LocalEventsList,LocalConversationState)Proposed Fix
BUILTIN_TOOLStosrc/conversation/builtin-tools.ts— pure data, no dependenciesLocalEventsListandLocalConversationStatetosrc/conversation/local-state.ts— they're independent classesrun()+handleToolCall()+executeBuiltinTool()) into a composableAgentRunnerclass thatLocalConversationdelegates toThis would bring
LocalConversationdown to ~400-500 lines focused on orchestration.Impact
Medium — improves readability and testability. Each extracted module can be unit-tested independently.
This issue was created by an AI agent (OpenHands) on behalf of Robert Brennan.