Skip to content

Conversation

@xingyaoww
Copy link
Contributor

Summary

This PR updates the SDK persistence documentation to clarify that the persistence directory contains JSON files similar to trajectory.json from OpenHands V0, and moves the Persistence guide to top-level in the navigation.

Changes Made

  1. Added Persistence Directory Structure section in sdk/guides/convo-persistence.mdx:

    • Explains that setting persistence_dir creates JSON files that mirror trajectory.json from V0
    • Shows directory structure with conversation ID-based filenames
    • Clarifies that each JSON file contains serialized conversation state with all events, messages, and metadata
  2. Moved Persistence to top-level in docs.json:

    • Moved sdk/guides/convo-persistence from "Conversation Features" group to top-level under "Guides"
    • Now appears alongside other core features like custom-tools, mcp, and skill

Context

Users were asking about how to access trajectory data similar to the trajectory.json file available in the OpenHands Web UI. This documentation update clarifies that the SDK provides the same capability through the persistence_dir parameter.

Related to the discussion about making persistence more discoverable and documenting the JSON file format compatibility with V0.

@xingyaoww can click here to continue refining the PR

openhands-agent and others added 2 commits November 3, 2025 15:06
…-level

- Add information about persistence directory containing JSON files similar to trajectory.json from V0
- Move Persistence guide from Conversation Features to top-level in SDK Guides
- Include directory structure example showing how conversations are stored
Synced from agent-sdk ref: main
openhands-agent and others added 2 commits November 3, 2025 15:12
…versation

- Clarify structure is .conversations/<conversation-id>/ with each conversation in its own subdirectory
- Update directory tree to show state.json files within conversation subdirectories
└── ...
```

Each `state.json` file contains the serialized conversation state with all events, messages, and metadata - similar to how `trajectory.json` worked in V0. This makes it easy to inspect, debug, or migrate conversation data between systems.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

I'm on it! xingyaoww can track my progress at all-hands.dev

Copy link

Choose a reason for hiding this comment

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

Summary

I've successfully corrected the persistence directory structure documentation in PR #68 based on the actual SDK source code.

Changes Made:

Fixed the "Persistence Directory Structure" section in sdk/guides/convo-persistence.mdx to accurately reflect the SDK implementation:

  1. Corrected default path: Changed from .conversations/ to workspace/conversations/ (the actual default from state.py)

  2. Fixed filename: Changed state.json to base_state.json (the actual constant from persistence_const.py)

  3. Added missing structure: Documented the events/ subdirectory that contains individual event files

  4. Added event file pattern: Showed the naming convention event-00000-<event-id>.json with sequential indexing

  5. Improved clarity: Explained that base_state.json holds core conversation state while individual events are stored separately for granular access

The documentation now accurately matches the implementation in the SDK's state.py and persistence_const.py files.

Commit: a9fedb5 - "Fix persistence directory structure documentation"
Status: Pushed to branch sdk-persistence-docs-update

View full conversation

- Update directory structure to show accurate file organization from SDK source
- Change default path from .conversations/ to workspace/conversations/
- Show base_state.json (not state.json) as the main state file
- Document events/ subdirectory with individual event files
- Add event file naming pattern (event-{idx:05d}-{event-id}.json)
- Clarify that events are stored separately for granular access

Co-authored-by: openhands <openhands@all-hands.dev>
- Explain that events/ directory contains the same data as trajectory.json from V0
- Highlight the benefit of splitting into individual files (performance, granular access)
- Mention memory efficiency advantage

Co-authored-by: openhands <openhands@all-hands.dev>
@xingyaoww xingyaoww marked this pull request as ready for review November 3, 2025 17:27
@xingyaoww xingyaoww requested a review from enyst as a code owner November 3, 2025 17:27
@xingyaoww xingyaoww requested a review from mamoodi November 3, 2025 17:27
Copy link
Contributor

@neubig neubig left a comment

Choose a reason for hiding this comment

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

LGTM, but is there a way we can use these with the trajectory visualizer?

@xingyaoww
Copy link
Contributor Author

@neubig not really, we need to rewrite the visualizer for new event schema :(

@xingyaoww xingyaoww merged commit 1de10c1 into main Nov 3, 2025
2 checks passed
@xingyaoww xingyaoww deleted the sdk-persistence-docs-update branch November 3, 2025 18:19
enyst pushed a commit that referenced this pull request Nov 8, 2025
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.

6 participants