OpenHands / OpenHands/software-agent-sdk

Split LocalConversation (953 lines) into smaller, focused modules

Open
#4,734 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
1.1k
Forks
539
Avg merge
1d 19h
Merged PRs (30d)
137

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/conversation/local-conversation.ts and review BUILTIN_TOOLS, LocalEventsList, LocalConversationState, run(), handleToolCall(), and executeBuiltinTool(). Use the proposed src/conversation/builtin-tools.ts and src/conversation/local-state.ts boundaries, then assess the AgentRunner extraction; done means responsibilities are separated and the extracted modules can be unit-tested independently.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.