Skip to content

feat: Add generic preset metadata field to Automation model #56

@malhotra5

Description

@malhotra5

Summary

Follows #51. Once repository support lands for preset endpoints, we should record the repository configuration (and other preset-specific data) in a generic metadata field that the UI can consume.

Background

Preset automations (/v1/preset/prompt and /v1/preset/plugin) are built from user-provided configuration that gets packaged into a tarball. Currently, only the prompt field is stored on the Automation model (see models.py:56). The generated tarball contains additional configuration that would be useful for the UI to display and for users to understand what their automation does:

  1. Repositories (from feat: add repository support to preset automation endpoints #51) — cloned into the sandbox at runtime
  2. Plugins — the PluginSource list used by /v1/preset/plugin (stored in plugins_config.json inside tarball)
  3. Prompt — already stored as a top-level field, but could be included in metadata for consistency

Proposal

Add a preset_metadata JSONB column to the Automation model:

# Preset-specific metadata (populated by preset endpoints, NULL for custom SDK automations)
preset_metadata: Mapped[dict | None] = mapped_column(JSONB, nullable=True)

Metadata Schema

The field is intentionally generic to accommodate future presets:

{
  "preset_type": "prompt" | "plugin",
  "prompt": "...",
  "plugins": [{"source": "github:owner/repo", "ref": "v1.0.0"}],
  "repos": [{"url": "OpenHands/repo", "ref": "main"}]
}

For prompt presets: preset_type, prompt, repos (once #51 lands)
For plugin presets: preset_type, prompt, plugins, repos

Changes Required

  1. models.py — Add preset_metadata JSONB column
  2. schemas.py — Add preset_metadata: dict | None to AutomationResponse
  3. preset_router.py — Populate preset_metadata when creating automations:
    • Prompt preset: {"preset_type": "prompt", "prompt": body.prompt, "repos": [...]}
    • Plugin preset: {"preset_type": "plugin", "prompt": body.prompt, "plugins": [...], "repos": [...]}
  4. Migration — Add the new column

Note

This does not apply to custom SDK automations (created via /v1 with a user-uploaded tarball), which will have preset_metadata = NULL.


This issue was created by an AI assistant (OpenHands).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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