Skip to content

Agent Server: Persist settings to disk and expose CRUD endpoints #3034

@xingyaoww

Description

@xingyaoww

Summary

The SDK already has well-structured settings models (OpenHandsAgentSettings, ACPAgentSettings, ConversationSettings) with schema versioning, migration support (from_persisted()), and form-schema export (export_schema()). However, the agent-server never actually persists or loads these settings. The settings_router.py only serves schema metadata (GET /settings/agent-schema, GET /settings/conversation-schema) — it tells the frontend what fields exist but never reads or writes actual values.

This means:

  • There is no settings file on disk
  • The frontend cannot save or retrieve user preferences
  • Every StartConversationRequest must provide the full Agent configuration inline — there are no "use my saved settings" defaults

What's Needed

1. A settings file path in the agent-server Config

Add a configurable settings_path: Path (defaulting to e.g. workspace/settings/ or ~/.openhands/settings/) to the agent-server Config model so the server knows where to read/write settings files.

2. GET /settings/agent — Load persisted agent settings

Return the currently persisted AgentSettings values from disk. If no file exists, return the defaults from default_agent_settings(). Use AgentSettings.from_persisted(data) to handle any schema migrations on load.

3. PUT /settings/agent — Save agent settings to disk

Accept an AgentSettingsConfig payload (the discriminated union of OpenHandsAgentSettings | ACPAgentSettings), validate it via validate_agent_settings(), and persist it to disk using model_dump() with the current schema_version.

4. GET /settings/conversation — Load persisted conversation settings

Return the currently persisted ConversationSettings values from disk. If no file exists, return defaults. Use ConversationSettings.from_persisted(data) for migration support.

5. PUT /settings/conversation — Save conversation settings to disk

Accept a ConversationSettings payload, validate, and persist to disk.

6. Default settings injection into conversation creation

When StartConversationRequest is received without an explicit agent (or with partial config), the agent-server should load the persisted settings and use ConversationSettings.create_request() to fill in defaults. This closes the loop: settings saved via the UI automatically apply to new conversations.

Context

The SDK plumbing is ready:

  • ConversationSettings has schema_version, from_persisted(), create_request(), and model_dump()
  • AgentSettings (discriminated union) has from_persisted(), schema_version, migrations via _apply_persisted_migrations
  • OpenHandsAgentSettings.create_agent() and ACPAgentSettings.create_agent() build fully configured agent objects from settings
  • The migration framework (_AGENT_SETTINGS_MIGRATIONS, _CONVERSATION_SETTINGS_MIGRATIONS) supports forward-compatible schema evolution

This is a key requirement for the agent-server: "Settings are persisted to disk".

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions