Skip to content

Split LocalConversation (953 lines) into smaller, focused modules #110

@rbren

Description

@rbren

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

  1. Extract BUILTIN_TOOLS to src/conversation/builtin-tools.ts — pure data, no dependencies
  2. Extract LocalEventsList and LocalConversationState to src/conversation/local-state.ts — they're independent classes
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions