Skip to content

[FEATURE]: Will 2.0 config hot-reload expose an HTTP/SDK trigger for headless serve? #43698

Closed

Description

@jayati-naik

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Context

I see reload is being worked on for 2.0 (e.g. #42478, #42898), while earlier
generic requests (#10899, #22213, #23304, #4734) were closed. My use case is
different from those, so before I open a PR I want to check it fits your 2.0
direction.

Use case

Running opencode serve as a long-lived, headless backend driven over the
HTTP API / SDK (not the TUI). The selectable model catalog can change while the
process runs (a model added/removed/re-priced in an upstream OpenAI-compatible
gateway, or an operator curating the roster). Today the catalog is resolved once
per instance at first access and cached for the process lifetime, so the only
way to pick up a change is to restart serve — disruptive for a multi-session
backend.

This is NOT the file-watcher from #22213 and NOT the TUI /reload from #23304.
It's an explicit, programmatic trigger for embedded deployments.

Question

Will the 2.0 reload work expose a way to trigger a config re-read + provider/
model catalog rebuild over the HTTP API / SDK (e.g. POST {instance}/config/reload)?

If not, I'd like to propose a small endpoint on the experimental instance
config group that reuses the existing InstanceStore.reload machinery
(the same path handlers/project.ts initGit already uses via
markInstanceForReload) to rebuild Config + Provider state from disk. Happy
to submit the PR if that direction is welcome — flagging as a design-review item
per CONTRIBUTING first.

Activity

  1. jayati-naik commented on Aug 20, 2026

    @jayati-naik
    Author

    Follow-up: we're pinned to the v1.18.x line and can't move to v2 until it has a stable release, so I'd specifically like to request this fix be patched into the current v1.18.x line rather than v2-only.

    Proposed as minimal and opt-in, so it's a no-op unless explicitly enabled — no behavior change for existing users:

    A POST {instance}/config/reload on the experimental instance API that reuses the existing InstanceStore.reload machinery to rebuild Config + Provider (model/provider catalog) state from disk, gated behind an env flag (defaulting off) — similar in spirit to the earlier OPENCODE_CONFIG_HOT_RELOAD prototype in #4285.
    I'm happy to submit this as a small, self-contained PR against the v1 line (endpoint + handler + test) if you'd accept it. Could you confirm whether a v1.18.x backport is acceptable, or whether runtime reload is strictly v2-only?

  2. neohiro commented on Aug 29, 2026

    @neohiro

    File-Based Trigger + Idle Sessions-Only Reload

    This is exactly the right ask. Adding use-case detail to push it forward:

    Trigger Surface

    Beyond /reload slash command and HTTP/SDK trigger for headless serve, a simple opencode reload-config CLI subcommand is the lowest-friction trigger. Symmetric with the existing opencode serve, opencode run, opencode auth. No new mental model.

    Safety Conditions (built in)

    Reload should be gated on sessions-idle, with a clear error otherwise:

    $ opencode reload-config
      Reloading config...
      ✗ Aborted: 3 sessions are active.
        Use --force to reload anyway (active sessions will keep their state).
    

    --force reload applies config to all sessions; without it, only idle sessions adopt the new config.

    Related Adjacent Issues

    These would all be resolved or substantially helped by a unified reload:

    Plugin Angle

    A plugin could subscribe to config.reloaded events and re-initialize their state — letting plugins be dynamically configurable without restart, which unlocks live-tuning workflows.

    One Final Note

    The current approach of "edit JSON, restart OpenCode, lose session context" is a significant friction point for power users who iterate on config. A 50ms reload gated on idle sessions would make OpenCode feel significantly more alive.


    🦙 Creative Monkey at FrenzyPenguin Media — open-source security hardening & privacy tools

  3. neohiro commented on Aug 29, 2026

    @neohiro

    Hey @thdxr @adamdotdevin @fwang @Brendonovich — fully behind this. Adding: a simple opencode reload-config CLI subcommand (symmetric with opencode serve, opencode run) plus a --force flag for active-session reload. Also flagging config.reloaded as a plugin event to enable dynamic plugin re-initialization. Resolves #42478, #30955, #39777 as a side effect. 🦙 Creative Monkey at FrenzyPenguin Media

  4. jayati-naik commented on Sep 1, 2026

    @jayati-naik
    Author

    Thanks @neohiro , agree with all of this, and it lines up with the existing InstanceStore.reload machinery, so the surface (reload-config CLI + HTTP/SDK trigger + config.reloaded plugin event, idle-gated with --force) is small and additive.

    @thdxr @adamdotdevin @fwang @Brendonovich , the only thing blocking a PR is one decision: is a v1.18.x backport acceptable, or is runtime reload strictly v2-only? We're pinned to v1.18.x and can't move to v2 until it's stable, so a v2-only answer means we can't consume this. If v1 is OK, I'll open a small self-contained PR (endpoint + handler + test) behind an off-by-default flag. Just need a yes/no on the v1 line.

  5. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for checking before opening a PR, @jayati-naik! You're asking whether v2 has a programmatic way to make a long-running headless opencode serve re-read its config and rebuild the provider/model catalog without restarting.

    It already does, since v2.1.0:

    • HTTP: POST /api/location/reload. It shuts down and rebuilds every loaded location, so config, providers and models are read fresh. Pending permissions and forms are cancelled, running sessions carry on with the rebuilt services at their next step, and a location.shutdown event is emitted so clients can recover. It responds once all the rebuilds have finished.
    • SDK: client.location.reload() in @opencode/client.
    • CLI: opencode reload, which calls that endpoint on the running server.

    The internals mentioned in the issue (InstanceStore.reload, markInstanceForReload, initGit in handlers/project.ts) are from the 1.x codebase and don't exist in v2, so a new config/reload endpoint would duplicate this one. If you're on 1.x, upgrading to v2 (@opencode/cli) gives you this endpoint.

    Related issues you may want to follow for a multi-session backend:

    If this endpoint doesn't cover your use case (for example, you need to reload a single location, or refresh only the catalog without rebuilding everything), please reply with the details and maintainers will consider it.

  6. neriousy commented on Nov 13, 2026

    @neriousy
    Member

    Closing as completed. V2 can reload config without a restart in three ways: the POST /api/location/reload endpoint, client.location.reload() in the SDK, and the opencode reload command (see the CLI docs). Each one rebuilds the loaded locations, so config and providers are read again. Config files are also watched, and a change triggers a reload automatically. Runtime reload exists in V2 only, and V1 is frozen, so there won't be a 1.18 backport. If you need to reload just one location, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions