OpenHands / OpenHands/software-agent-sdk
Split LocalConversation (953 lines) into smaller, focused modules
Nobody has claimed this yet.
- 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_TOOLSconstant — ~90 lines of JSON) - Built-in tool execution (
executeBuiltinTool()) - Event emission (two systems: legacy
emitEventand typedemitTypedEvent) - Secret masking
- Stuck detection integration
- Confirmation handling
- Message history management
- Title generation
- Internal state classes (
LocalEventsList,LocalConversationState)
Proposed Fix
- Extract
BUILTIN_TOOLStosrc/conversation/builtin-tools.ts— pure data, no dependencies - Extract
LocalEventsListandLocalConversationStatetosrc/conversation/local-state.ts— they're independent classes - Consider extracting the agent loop (
run()+handleToolCall()+executeBuiltinTool()) into a composableAgentRunnerclass thatLocalConversationdelegates 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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