Skip to content

Feature: Add skill hot-reload / refresh mechanism (skills cached forever, no way to refresh without restart) #20010

Closed

Description

@hy-pony

Problem / 问题

When running OpenCode in Web mode (opencode web), skills are loaded once on the first request and cached forever (ScopedCache with TTL: infinity). There is no way to refresh skills without restarting the entire OpenCode process.

在 Web 模式 (opencode web) 下,skills 仅在首次请求时加载一次,之后永久缓存(ScopedCache 的 TTL 设置为 infinity)。除了重启 OpenCode 进程外,没有任何方式可以刷新 skills。

Current Behavior / 当前行为

  1. Skills are loaded via loadSkills() and stored in InstanceState backed by ScopedCache
  2. The cache key is Instance.directory, with capacity Infinity and TTL infinity
  3. All sessions within the same directory share the same Instance, so creating a new session does NOT reload skills
  4. The only code path that triggers cache invalidation is Instance.reload(), which is only called from POST /project/git/init

  1. Skills 通过 loadSkills() 加载,存储在由 ScopedCache 支持的 InstanceState 中
  2. 缓存 key 是 Instance.directory,容量为 Infinity,TTL 为 infinity
  3. 同一目录下所有 session 共享同一个 Instance,因此新建会话不会重新加载 skills
  4. 唯一触发缓存失效的代码路径是 Instance.reload(),仅在 POST /project/git/init 路由中被调用

Expected Behavior / 期望行为

Users should be able to refresh skills without restarting OpenCode. This is especially important during skill development, where frequent iteration requires quick feedback loops.

用户应该能够在不重启 OpenCode 的情况下刷新 skills。这在 skill 开发过程中尤其重要,频繁迭代需要快速的反馈循环。

Proposed Solutions / 建议方案

Any of the following (or a combination) would solve this:

以下任一方案(或组合)均可解决此问题:

1. API endpoint for skill refresh / Skill 刷新 API

Add a dedicated endpoint (e.g., POST /skills/reload) that invalidates the skill cache and re-runs loadSkills().

添加一个专用的 API 端点(如 POST /skills/reload),用于使 skill 缓存失效并重新执行 loadSkills()。

2. File watcher on skill directories / 监听 skill 目录变化

Use fs.watch or a similar mechanism to watch skill directories (~/.claude/skills/, ~/.config/opencode/skills/, etc.) for changes, and automatically invalidate the cache when files are added/modified/removed.

使用 fs.watch 或类似机制监听 skill 目录(~/.claude/skills/、~/.config/opencode/skills/ 等)的变化,当文件被添加/修改/删除时自动使缓存失效。

3. Reasonable TTL / 合理的 TTL

Replace infinity TTL with a reasonable duration (e.g., 30 seconds or 1 minute), so skills are periodically re-scanned.

将 infinity TTL 替换为合理的时长(如 30 秒或 1 分钟),使 skills 能够被定期重新扫描。

Environment / 环境信息

  • OpenCode version: 1.3.3
  • Mode: Web (opencode web)
  • OS: Linux (Ubuntu 20.04)

Related Code / 相关代码

Key locations in the bundled source (from decompiled binary analysis):

  • src/skill/index.ts — loadSkills() function, Skill.layer with InstanceState.make()
  • src/effect/instance-state.ts — ScopedCache with infinity TTL
  • src/provider/instance.ts — Instance.provide(), Instance.reload(), instance cache by directory

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    webRelates to opencode on web / desktop
    on Mar 30, 2026
  2. github-actions commented on Mar 30, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Feature requests must use the Feature Request issue template, which requires a verification checkbox confirming the feature hasn't been suggested before, and the title must start with [FEATURE]:

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. hy-pony commented on Mar 30, 2026

    @hy-pony
    Author

    Closing as duplicate of #8751 and #19050. Will add our source code analysis there. Thanks for pointing this out!

    关闭,因为与 #8751 和 #19050 重复。会在 #8751 补充我们的源码分析。感谢指出!

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

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)needs:complianceThis means the issue will auto-close after 2 hours.webRelates to opencode on web / desktop

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions