Skip to content

fix(settings): remove module-level AgentStore singleton - #839

Open
github-actions[bot] wants to merge 1 commit into
mainfrom
fix/code-quality/remove-agent-store-singleton
Open

github-actions[bot] wants to merge 1 commit into
mainfrom
fix/code-quality/remove-agent-store-singleton

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Removes the module-level agent_store = AgentStore() singleton in tui/modals/settings/utils.py by refactoring save_settings() to accept an optional agent_store parameter.

Changes

  • Removed module-level agent_store singleton from utils.py
  • Added agent_store: AgentStore | None = None parameter to save_settings()
  • Function creates AgentStore() on demand if not provided, maintaining backward compatibility
  • Updated SettingsScreen to pass its existing agent_store instance
  • Updated tests to pass fake store directly instead of monkeypatching

Benefits

  • Testability: Tests can now pass a mock store directly as a parameter
  • Encapsulation: No implicit global state created at import time
  • Dependency injection: Callers can provide their own store instance

Related Issue

Addresses findings from #838

Testing

  • Linting passes (make lint)
  • Tests pass (make test)

This PR was automatically generated by the Code Quality Report workflow.

Refactor save_settings() to accept an optional agent_store parameter
instead of relying on a module-level singleton. This improves:
- Testability: tests can now pass a mock store directly
- Encapsulation: no implicit global state at import time
- Dependency injection: callers can provide their own store instance

The function creates an AgentStore on demand if not provided, maintaining
backward compatibility.

Addresses item from code quality report.

Closes #838

Co-authored-by: openhands <openhands@all-hands.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants