Skip to content

fix(skills): preserve skillKey in SkillSnapshot for correct env override lookup - #94189

Closed
xydttsw wants to merge 1 commit into
openclaw:mainfrom
xydttsw:fix/issue-94146-snapshot-skillkey
Closed

xydttsw wants to merge 1 commit into
openclaw:mainfrom
xydttsw:fix/issue-94146-snapshot-skillkey

Conversation

@xydttsw

@xydttsw xydttsw commented Jun 17, 2026

Copy link
Copy Markdown

Summary

SkillSnapshot.skills[] stores name, primaryEnv, and requiredEnv but does not persist the resolved skillKey. When a skill has metadata.skillKey that differs from its display name (e.g., name="Pretty Weather", skillKey="weather"), the snapshot env override logic (applySkillEnvOverridesFromSnapshot()) looks up config by skill.name instead of skillKey — missing the configured env/apiKey stored under skills.entries.<skillKey>.

Changes

Three files touched:

  1. src/skills/types.ts — added optional skillKey?: string to SkillSnapshot.skills[] array element type.

  2. src/skills/loading/workspace.ts — populate skillKey from entry.metadata.skillKey in buildWorkspaceSkillSnapshot().

  3. src/skills/runtime/env-overrides.ts — use skill.skillKey ?? skill.name for config lookup in applySkillEnvOverridesFromSnapshot(), preserving backward compatibility with existing snapshots that only have name.

  4. src/skills/loading/skills.test.ts — added a regression test where name !== skillKey, verifying that env overrides are correctly resolved via skillKey.

Real behavior proof

Behavior or issue addressed

SkillSnapshot loses skillKey, causing snapshot env overrides to miss skills.entries. config.

Real environment tested

Code review of the snapshot builder, type definition, and env override lookup chain. The fix is verified by the existing test suite and a new regression test.

Exact steps or command run after this patch

  1. A skill with metadata.skillKey: "weather" and name: "Pretty Weather" is loaded into a snapshot. The snapshot now includes skillKey: "weather".
  2. applySkillEnvOverridesFromSnapshot() uses skill.skillKey ?? skill.name → resolves to "weather" → finds config at skills.entries.weather.apiKey → injects the env var. Verified by the new test.
  3. Older snapshots without skillKey still resolve via skill.name fallback (existing tests cover this).

Evidence after fix

The diff is 4 files, +49/-10 lines:

  • Type definition adds one optional field
  • Snapshot builder adds one field population
  • Env override logic changes two references from skill.name to resolvedKey = skill.skillKey ?? skill.name
  • New test directly validates the name!=skillKey case

Observed result after the fix

Skills configured with a distinct metadata.skillKey now receive their env/apiKey overrides at runtime when loaded from a SkillSnapshot. Previously the config was silently missed, causing skills to operate without their required credentials. Backward compatibility with existing snapshots is preserved.

What was not tested

Full integration test with a live OpenClaw gateway (not available in this environment). The fix targets a focused data-propagation gap and is covered by unit tests.

Related

Fixes #94146

Co-Authored-By: Claude [email protected]

…ide lookup

SkillSnapshot.skills[] only stored name, primaryEnv, and requiredEnv,
but did not persist the resolved skillKey. When a skill has a
metadata.skillKey that differs from its display name (e.g.
name='Pretty Weather' with skillKey='weather'), the snapshot env
override logic looked up config by skill.name instead of skillKey,
missing the configured env/apiKey stored under
skills.entries.<skillKey>.

Fix:
1. Add optional skillKey to SkillSnapshot.skills type
2. Populate skillKey from entry.metadata.skillKey in the snapshot builder
3. Use skill.skillKey ?? skill.name for config lookup in
   applySkillEnvOverridesFromSnapshot()

Fixes openclaw#94146.

Co-Authored-By: Claude <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 17, 2026
@clawsweeper

clawsweeper Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper review: did not complete due to Codex infrastructure failure. Reviewed June 17, 2026, 11:25 AM ET / 15:25 UTC.

Summary
Review failed before ClawSweeper could summarize the requested change.

PR surface: Source +2, Tests +37. Total +39 across 4 files.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: vector/embedding metadata: src/skills/loading/workspace.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Not assessed.
Failure reason: invalid structured output.

This is a ClawSweeper/Codex infrastructure failure, not a PR readiness or patch-quality verdict.
Keep any merge decision on the normal maintainer review path until ClawSweeper can complete a fresh review.

Risk before merge

  • [P1] No close action taken because the review did not complete.

Maintainer options:

  1. Decide the mitigation before merge
    Retry the Codex review after fixing the execution failure.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • Review did not complete, so no work-lane recommendation was made.
Review details

Best possible solution:

Retry the Codex review after fixing the execution failure.

Do we have a high-confidence way to reproduce the issue?

Unclear. The review failed before ClawSweeper could establish a reproduction path.

Is this the best way to solve the issue?

Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against a7f96847ce2d.

Evidence reviewed

PR surface:

Source +2, Tests +37. Total +39 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 12 10 +2
Tests 1 37 0 +37
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 49 10 +39

What I checked:

  • failure reason: invalid structured output.
  • codex failure detail: Codex review failed for this PR with exit 0 and wrote invalid JSON or schema-invalid output to /home/runner/work/clawsweeper/clawsweeper/artifacts/event/codex/94189.json: decision.rootCauseCluster.currentItemRelationship fixed_by_candidate requires a canonical PR.
  • codex stderr: No stderr captured.
  • codex stdout: "detail":"v2026.6.8 still uses skill.name for snapshot lookup, and the PR head is not an ancestor of origin/main or any tag checked locally.","file":"src/skills/runtime/env-overrides.ts","line":263,"command":"git show v2026.6.8:src/skills/runtime/env-overrides.ts 2>/dev/null | nl -ba | sed -n '224,280p'; git merge-base --is-ancestor 6b31f93 origin/main; git tag --contains 6b31f93","sha":"844f405ac1be805d5c598922a37254f12ab6d765"},{"label":"History provenance","detail":"git blame shows the current skills snapshot/env override implementation was introduced in commit 9d04064e736a5cd3d904fe00962b908f9a917400, authored and committed by vincentkoc.","file":"src/skills/runtime/env-overrides.ts","line":224,"command":"git blame -L 224,280 origin/main -- src/skills/runtime/env-overrides.ts; gh api repos/openclaw/openclaw/commi.

Likely related people:

  • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)
How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

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

Labels

size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SkillSnapshot loses skillKey, causing snapshot env overrides to miss skills.entries.<skillKey>

1 participant