Skip to content

fix(skills): use skillKey for env config lookup in snapshots - #9221

Closed
gavinbmoore wants to merge 1 commit into
openclaw:mainfrom
gavinbmoore:fix/9207-skill-env-subagent
Closed

gavinbmoore wants to merge 1 commit into
openclaw:mainfrom
gavinbmoore:fix/9207-skill-env-subagent

Conversation

@gavinbmoore

@gavinbmoore gavinbmoore commented Feb 5, 2026 •

Copy link
Copy Markdown

Summary

When skills have a custom skillKey in their metadata (e.g., skillKey: 'trello' for a skill named trello-skill), the env var config lookup in applySkillEnvOverridesFromSnapshot was failing because it used skill.name instead of the skillKey.

This caused skill env vars defined in skills.entries.<skill>.env to not be injected into subagent exec commands when the skill uses a custom skillKey for the config.

Changes

  • Add skillKey to SkillSnapshot.skills type (stored only when it differs from name)
  • Update buildWorkspaceSkillSnapshot to include skillKey in the snapshot
  • Update applySkillEnvOverridesFromSnapshot to use skillKey (with fallback to name) for config lookup
  • Add test case for skillKey-based env lookup

Testing

  • All existing tests pass
  • New test case verifies skillKey-based env lookup works

Fixes #9207

Greptile Overview

Greptile Summary

This PR fixes a config lookup bug for skill environment overrides when a skill uses a custom skillKey in its frontmatter metadata. It updates the serialized SkillSnapshot shape to optionally include skillKey (only when it differs from name), updates snapshot building to store it, and updates applySkillEnvOverridesFromSnapshot to resolve config entries by skillKey ?? name. A new unit test covers the skillKey-based lookup path.

This change integrates with the existing skills pipeline by affecting the snapshot used to avoid reloading skills during embedded runs (src/agents/pi-embedded-runner/*), ensuring env injection uses the same config keying as the non-snapshot path (applySkillEnvOverrides, which already resolves the skill key from frontmatter).

Confidence Score: 4/5

  • This PR is close to safe to merge, but there is a concrete snapshot type mismatch that can break session snapshot persistence/compatibility and may drop the new skillKey field.
  • Core logic change is small and aligns snapshot env lookup with the existing non-snapshot codepath, and the new unit test covers the intended behavior. However, SessionSkillSnapshot in src/config/sessions/types.ts was not updated to include skillKey, which can cause type incompatibilities and prevent skillKey from being retained when snapshots are stored/loaded via session types.
  • src/config/sessions/types.ts

When skills have a custom skillKey in their metadata (e.g., skillKey: 'trello'
for a skill named 'trello-skill'), the env var config lookup in
applySkillEnvOverridesFromSnapshot was failing because it used skill.name
instead of the skillKey.

Changes:
- Add skillKey to SkillSnapshot.skills when it differs from name
- Use skillKey (with fallback to name) in applySkillEnvOverridesFromSnapshot
  for config lookup

This fixes skill env vars not being injected into subagent exec commands
when the skill uses a custom skillKey.

Fixes openclaw#9207
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Feb 5, 2026

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps

greptile-apps Bot commented Feb 5, 2026

Copy link
Copy Markdown
Contributor
Additional Comments (1)

src/config/sessions/types.ts
Snapshot type mismatch
SkillSnapshot.skills was extended to include skillKey?: string (src/agents/skills/types.ts:82-87), but SessionSkillSnapshot.skills still has Array<{ name: string; primaryEnv?: string }>.

This will break type-level compatibility anywhere a SkillSnapshot is stored/loaded via SessionSkillSnapshot (e.g. session persistence / JSON parsing) and prevents skillKey from being carried through sessions. Please update SessionSkillSnapshot to match the new snapshot shape (or explicitly map/strip fields at the boundary).

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/config/sessions/types.ts
Line: 117:121

Comment:
**Snapshot type mismatch**
`SkillSnapshot.skills` was extended to include `skillKey?: string` (`src/agents/skills/types.ts:82-87`), but `SessionSkillSnapshot.skills` still has `Array<{ name: string; primaryEnv?: string }>`.

This will break type-level compatibility anywhere a `SkillSnapshot` is stored/loaded via `SessionSkillSnapshot` (e.g. session persistence / JSON parsing) and prevents `skillKey` from being carried through sessions. Please update `SessionSkillSnapshot` to match the new snapshot shape (or explicitly map/strip fields at the boundary).

How can I resolve this? If you propose a fix, please make it concise.

@vishaltandale00

Copy link
Copy Markdown
Contributor

Good fix! However, as Greptile noted, SessionSkillSnapshot in src/config/sessions/types.ts (line 119) needs to be updated to include the skillKey field to ensure compatibility when snapshots are persisted/loaded:

skills: Array<{ name: string; skillKey?: string; primaryEnv?: string }>;

Without this, the skillKey field will be dropped when the snapshot is stored in session state, breaking the fix for persisted sessions.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity and removed stale Marked as stale due to inactivity labels Feb 21, 2026
@mudrii

This comment was marked as spam.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Mar 7, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #pr-thunderdome-dangerzone on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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

Labels

agents Agent runtime and tooling stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skill env vars not injected into subagent exec commands

3 participants