Skip to content

fix(controller): ensure new skills are visible to agent on first ask#753

Merged
lefarcen merged 2 commits intofeat/medeo-video-skillfrom
fix/skill-bootstrap-ordering
Apr 1, 2026
Merged

fix(controller): ensure new skills are visible to agent on first ask#753
lefarcen merged 2 commits intofeat/medeo-video-skillfrom
fix/skill-bootstrap-ordering

Conversation

@lefarcen
Copy link
Copy Markdown
Collaborator

@lefarcen lefarcen commented Apr 1, 2026

What

Fix a race condition where newly bundled or installed skills are invisible to the agent, even though they're on disk and in the config allowlist.

Why

Two issues caused skills to be invisible:

  1. Cold-start ordering: syncAllImmediate() pushed the first config to OpenClaw before skillhubService.start() copied static/bundled skills to disk. The first compiled config was missing these skills.

  2. Stale snapshot in existing sessions: Even after a config push with the correct allowlist, OpenClaw's config-reload treats agents/skills changes as kind: "none" (no action). Existing sessions keep using a stale skills snapshot and never see newly added skills β€” until a full restart.

How

Fix 1 β€” Bootstrap ordering (skillhub-service.ts, bootstrap.ts):

  • Add SkillhubService.bootstrap() β€” runs syncNow() + copyStaticSkills() before the first config push
  • Called in bootstrapController() before syncAllImmediate()
  • All operations are idempotent; start() still calls them again safely

Fix 2 β€” Touch SKILL.md after config push (openclaw-sync-service.ts):

  • After syncAll successfully pushes a config change, touch one SKILL.md in the skills directory
  • This triggers OpenClaw's chokidar watcher β†’ bumpSkillsSnapshotVersion() β†’ existing sessions rebuild their snapshot on the next turn
  • Uses the existing OpenClawWatchTrigger.touchSkill() helper
  • Only fires when configPushed is true (no unnecessary touches)

Affected areas

  • Controller (backend / API)

Checklist

  • pnpm typecheck passes
  • pnpm test passes (new: 4 bootstrap ordering tests)
  • Verified with packaged DMG: agent recognizes newly bundled skill on first ask in existing session
  • No credentials or tokens in code or logs
  • No any types introduced

lefarcen added 2 commits April 2, 2026 00:43
…push

syncAllImmediate() ran before skillhubService.start(), so the first
compiled config was missing static/bundled skills that hadn't been
copied to disk yet. OpenClaw booted with an incomplete agent skills
allowlist, and because config-reload treats agents/skills changes as
kind "none", the snapshot was never rebuilt for existing sessions.

Add SkillhubService.bootstrap() β€” runs syncNow + copyStaticSkills
before the first config push β€” so the compiled allowlist is complete
from the start.
…apshot

After syncAll pushes a new config (with updated agent skills allowlist),
touch one SKILL.md in the skills directory to trigger OpenClaw's chokidar
watcher β†’ bumpSkillsSnapshotVersion. Without this, existing sessions keep
using a stale skills snapshot because OpenClaw's config-reload treats
agents/skills changes as kind "none" (no hot-reload action).
@lefarcen lefarcen changed the title fix(controller): bootstrap skill ledger before first OpenClaw config push fix(controller): ensure new skills are visible to agent on first ask Apr 1, 2026
@lefarcen lefarcen changed the base branch from main to feat/medeo-video-skill April 1, 2026 17:35
@lefarcen lefarcen merged commit 6a88083 into feat/medeo-video-skill Apr 1, 2026
8 checks passed
lefarcen added a commit that referenced this pull request Apr 2, 2026
* feat(skill): add Medeo Video as bundled static skill

Add AI video generation skill (Seedance 2.0 via Medeo Gateway) to the
bundled skills shipped with the desktop app.

- SKILL.md with agent instructions for video generation workflow
- medeo_video.py: CLI for setup, check, upload, spawn-task, recover
- feishu_send_video.py: Feishu video delivery script
- Register "medeo-video" in STATIC_SKILL_SLUGS

* feat(skill): hardcode gateway URL, default duration 15s, max 20s, remove --gateway-url

* feat(skill): passthrough env vars to sub-agent, expand feishu credential lookup

* fix(controller): ensure new skills are visible to agent on first ask (#753)

* fix(controller): bootstrap skill ledger before first OpenClaw config push

syncAllImmediate() ran before skillhubService.start(), so the first
compiled config was missing static/bundled skills that hadn't been
copied to disk yet. OpenClaw booted with an incomplete agent skills
allowlist, and because config-reload treats agents/skills changes as
kind "none", the snapshot was never rebuilt for existing sessions.

Add SkillhubService.bootstrap() β€” runs syncNow + copyStaticSkills
before the first config push β€” so the compiled allowlist is complete
from the start.

* fix(controller): touch SKILL.md after config push to bump OpenClaw snapshot

After syncAll pushes a new config (with updated agent skills allowlist),
touch one SKILL.md in the skills directory to trigger OpenClaw's chokidar
watcher β†’ bumpSkillsSnapshotVersion. Without this, existing sessions keep
using a stale skills snapshot because OpenClaw's config-reload treats
agents/skills changes as kind "none" (no hot-reload action).

* feat(skill): cron-based progress monitoring for medeo video (#754)

* feat(skill): add progress notifications for medeo video generation

Sub-agent now sends stage-change updates to the user via message tool
(composing β†’ rendering β†’ storing) instead of silently waiting until
completion. Poll interval reduced from 3min to 1min for faster feedback.

Final video URL is returned as plain text to the main agent so it can
deliver with conversation context, keeping the interaction natural.

* feat(skill): use cron-based progress monitoring for medeo video

Replace sessions_spawn sub-agent approach with cron systemEvent:
- Main agent sets a 2-minute cron after submitting a video task
- Each cron fires a systemEvent in the same session, prompting the
  agent to check task-status and update the user conversationally
- Agent decides whether to notify based on stage change and time
  since last update β€” no mechanical notifications
- task-status output reminds agent to remove cron when task finishes
- Support MEDEO_GATEWAY_URL env var override for local testing

* fix(skill): restore production gateway URL, strengthen completion delivery

- GATEWAY_URL defaults to production, overridable via MEDEO_GATEWAY_URL env
- SKILL.md: agent MUST send video URL on completion, not just report status

* fix(skill): hardcode production gateway URL

* feat(skill): add LibTV Video as bundled static skill

- Add libtv-video to STATIC_SKILL_SLUGS (pinned as first entry)
- Seedance 2.0 as default model, auto-appended to prompts
- Supports text-to-video, image-to-video, upload, session polling
- Includes recover command for session recovery after agent restart
- All user-facing output in English with friendly status messages

---------

Co-authored-by: lefarcen <935902669@qq.com>
lefarcen added a commit that referenced this pull request Apr 2, 2026
* feat(skill): add Medeo Video as bundled static skill

Add AI video generation skill (Seedance 2.0 via Medeo Gateway) to the
bundled skills shipped with the desktop app.

- SKILL.md with agent instructions for video generation workflow
- medeo_video.py: CLI for setup, check, upload, spawn-task, recover
- feishu_send_video.py: Feishu video delivery script
- Register "medeo-video" in STATIC_SKILL_SLUGS

* feat(skill): hardcode gateway URL, default duration 15s, max 20s, remove --gateway-url

* feat(skill): passthrough env vars to sub-agent, expand feishu credential lookup

* fix(controller): ensure new skills are visible to agent on first ask (#753)

* fix(controller): bootstrap skill ledger before first OpenClaw config push

syncAllImmediate() ran before skillhubService.start(), so the first
compiled config was missing static/bundled skills that hadn't been
copied to disk yet. OpenClaw booted with an incomplete agent skills
allowlist, and because config-reload treats agents/skills changes as
kind "none", the snapshot was never rebuilt for existing sessions.

Add SkillhubService.bootstrap() β€” runs syncNow + copyStaticSkills
before the first config push β€” so the compiled allowlist is complete
from the start.

* fix(controller): touch SKILL.md after config push to bump OpenClaw snapshot

After syncAll pushes a new config (with updated agent skills allowlist),
touch one SKILL.md in the skills directory to trigger OpenClaw's chokidar
watcher β†’ bumpSkillsSnapshotVersion. Without this, existing sessions keep
using a stale skills snapshot because OpenClaw's config-reload treats
agents/skills changes as kind "none" (no hot-reload action).

* feat(skill): cron-based progress monitoring for medeo video (#754)

* feat(skill): add progress notifications for medeo video generation

Sub-agent now sends stage-change updates to the user via message tool
(composing β†’ rendering β†’ storing) instead of silently waiting until
completion. Poll interval reduced from 3min to 1min for faster feedback.

Final video URL is returned as plain text to the main agent so it can
deliver with conversation context, keeping the interaction natural.

* feat(skill): use cron-based progress monitoring for medeo video

Replace sessions_spawn sub-agent approach with cron systemEvent:
- Main agent sets a 2-minute cron after submitting a video task
- Each cron fires a systemEvent in the same session, prompting the
  agent to check task-status and update the user conversationally
- Agent decides whether to notify based on stage change and time
  since last update β€” no mechanical notifications
- task-status output reminds agent to remove cron when task finishes
- Support MEDEO_GATEWAY_URL env var override for local testing

* fix(skill): restore production gateway URL, strengthen completion delivery

- GATEWAY_URL defaults to production, overridable via MEDEO_GATEWAY_URL env
- SKILL.md: agent MUST send video URL on completion, not just report status

* fix(skill): hardcode production gateway URL

* feat(skill): add LibTV Video as bundled static skill

- Add libtv-video to STATIC_SKILL_SLUGS (pinned as first entry)
- Seedance 2.0 as default model, auto-appended to prompts
- Supports text-to-video, image-to-video, upload, session polling
- Includes recover command for session recovery after agent restart
- All user-facing output in English with friendly status messages

* fix(skill): fix NoneType crash in libtv query, add tasks command

- Fix TypeError when task_result.images/videos is null (use `or []`)
- Fix NoneType crash when gateway returns no messages
- Add `tasks` command to list all tasks for current key

* fix(skill): restrict libtv result URL to libtv-res.liblib.art/sd-gen-save-img prefix

- Update LIBTV_RES_PATTERN to only match libtv-res.liblib.art/sd-gen-save-img/
- Ignore medeo-res.liblib.art gateway proxy URLs
- Add multi-session discipline SOP and URL rules to SKILL.md
- Add tasks command to SKILL.md command reference

* fix(skill): use correct API field names in libtv tasks command

- Use `video_url` instead of hallucinated `libtv_video_url`/`medeo_video_url`/`r2_video_url`
- Default backend to `libtv` instead of `medeo`
- Add `completed_at` timestamp to output

* fix(skill): persist result_urls to local for offline recovery

- Extend _save_session to store result_urls and completed_at
- Save results locally on completion in wait-and-deliver, query-session, tasks, recover
- Recover reads completed sessions from local (no API call), only checks pending via API
- Reduces hallucination: agent can always find video URLs from local file

---------

Co-authored-by: lefarcen <935902669@qq.com>
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.

2 participants