Skip to content

feat(sdk): allow custom FileStore injection#3252

Open
StatPan wants to merge 1 commit into
OpenHands:mainfrom
StatPan:feat/custom-filestore-injection
Open

feat(sdk): allow custom FileStore injection#3252
StatPan wants to merge 1 commit into
OpenHands:mainfrom
StatPan:feat/custom-filestore-injection

Conversation

@StatPan
Copy link
Copy Markdown
Contributor

@StatPan StatPan commented May 14, 2026

Summary

  • Add an optional file_store parameter to ConversationState.create() and LocalConversation.__init__()
  • Preserve the existing persistence_dir behavior when no custom store is provided
  • Document the interaction: an injected file_store owns state/EventLog persistence, while persistence_dir still sets observation paths
  • Add focused tests using InMemoryFileStore so this PR only covers the injection point, not any database backend

Motivation

Some SDK users run conversations in stateless or ephemeral environments where the local filesystem is not a durable EventLog store. This change lets callers provide their own FileStore implementation without adding any storage backend to the SDK core.

This is intentionally split from #2902: PostgreSQL support can remain external or be proposed separately. The API question here is only whether local SDK conversations can accept a caller-provided FileStore.

Test plan

  • uv run ruff format openhands-sdk/openhands/sdk/conversation/state.py openhands-sdk/openhands/sdk/conversation/impl/local_conversation.py tests/sdk/conversation/local/test_custom_file_store.py
  • uv run ruff check openhands-sdk/openhands/sdk/conversation/state.py openhands-sdk/openhands/sdk/conversation/impl/local_conversation.py tests/sdk/conversation/local/test_custom_file_store.py
  • uv run pytest tests/sdk/conversation/local/test_custom_file_store.py tests/sdk/conversation/test_directories.py tests/sdk/conversation/local/test_conversation_path_types.py -q
  • uv run pre-commit run --files openhands-sdk/openhands/sdk/conversation/state.py openhands-sdk/openhands/sdk/conversation/impl/local_conversation.py tests/sdk/conversation/local/test_custom_file_store.py
  • uv run python .github/scripts/check_sdk_api_breakage.py

Resolves StatPan#1

Co-authored-by: openhands <openhands@all-hands.dev>
Copy link
Copy Markdown
Collaborator

@all-hands-bot all-hands-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean dependency injection pattern with comprehensive tests and clear documentation. Maintains full backward compatibility while enabling custom FileStore implementations.

@StatPan
Copy link
Copy Markdown
Contributor Author

StatPan commented May 15, 2026

Hi @xingyaoww, #3252 splits out only the minimal custom FileStore injection point from #2902. CI is passing and the bot review approved it, but because this is a fork PR the QA Changes workflow is skipped and no human reviewer is currently requested.

Could you take a look or route this to the right maintainer when you have a chance? Thank you.

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.

Track upstream contribution: custom FileStore injection

2 participants