Skip to content

fix(gateway): keep skill_library in the deferred tool directory - #195368

Open
SebTardif wants to merge 2 commits into
openclaw:mainfrom
SebTardif:fix/skill-library-settle-directory
Open

SebTardif wants to merge 2 commits into
openclaw:mainfrom
SebTardif:fix/skill-library-settle-directory

Conversation

@SebTardif

@SebTardif SebTardif commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Every subagent announce or settle run rebuilt the parent session's Tooling section without skill_library. The system prompt suffix changed, so the parent's prompt cache was dropped. The next ordinary turn put the entry back and missed again.

A settle client is not the attributed user, so looking up authoring from that client still omitted the tool. The Gateway now remembers the session's last human skill_library shape and reuses it. The call is refused. A synthetic client that presents itself as a human turn still gets no tool.

Fixes #195328.

Evidence

Isolated Gateway from this worktree, xai/grok-4.7, OPENCLAW_CACHE_TRACE=1, session agent:main:proof195368, port 19031. Head f2a8a222d00.

Human turn: skill_library action list succeeded. The reply was listed.

Settle turn after sessions_spawn and sessions_yield:

[prompt-cache] cache read dropped 25088 -> 20224 runId=announce:requester-settle:...:yield-1 ... historyRewrite(message 13 (user) differs from the previous request; history must be append-only; changed fields: envelope.timestamp)
[tools] dispatch_action failed: SkillLibraryError: Skill library authoring is only available on a direct user turn. | FORBIDDEN

The settle cache miss is a history timestamp rewrite. It is not systemPromptSuffix / sections: Tooling. The parent human run and the settle run share system digest 7760898c02dc689e. No settle-denied skill was written.

Before this shape was remembered, the same Gateway sequence logged systemPromptSuffix (sections: Tooling) and Unknown tool id: skill_library.

Real behavior proof

  • Behavior or issue addressed: After a human turn, a subagent settle must keep skill_library in the parent prompt and must refuse a library write.
  • Real environment tested: macOS, Node v26.12.1, isolated state under /tmp, Gateway from f2a8a222d00, model xai/grok-4.7, loopback port 19031.
  • Exact steps or command run after this patch: node scripts/run-node.mjs gateway run on that worktree, then two node scripts/run-node.mjs agent --session-key agent:main:proof195368 turns: a skill_library list, then sessions_spawn plus sessions_yield followed by a skill_library create.
  • Evidence after fix: The console lines in Evidence. List succeeded. Settle invoked skill_library and got FORBIDDEN. The system digest matched the parent human run. The cache reason was not the Tooling section.
  • Observed result after fix: The settle prompt kept the directory entry. The create did not publish a skill.
  • What was not tested: A steer run as its own Gateway session. Steer uses the same non-human gate.

Summary

Human turns still mint the real capability and record defaultTarget plus multipleProfiles for the session. Later non-human turns reuse that shape and throw FORBIDDEN. A synthetic client on a human turn, and a session that has never had a human turn, still get no tool.

Settle and steer runs withheld personal authoring by omitting the
tool, so the parent prompt suffix changed and the cache missed.
Those runs now keep the same directory entry and refuse the call.

Fixes openclaw#195328

Signed-off-by: Sebastien Tardif <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Maintainer security review required

This external contributor PR changes sensitive security components. A maintainer must review these changes before merging.

Current SHA: f2a8a222d00e92a866c5be058cc0cf3336e36f93

These sensitive security changes were made:

  • src/gateway/skill-library-authoring.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

After reviewing the changes, post a new PR comment containing only approval commands, each on its own line:

/allow-security-sensitive-change

A later push requires a fresh approval comment.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 8, 2026
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR remembers a session’s human skill-library presentation and reuses it on non-human turns while refusing library operations.

Example: Session agent:main:proof195368 spawns a subagent and resumes after sessions_yield.

  • Before: The settle run loses skill_library from the deferred directory, changing the Tooling prompt section.
  • After: The settle run retains the entry, while an attempted library create returns FORBIDDEN.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-supported repair with relevant shipped-Gateway proof and no actionable findings; the memory-only presentation change requires no stored-data migration.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): The supplied reviewed-head macOS Gateway sequence exercises successful human listing, sessions_spawn/sessions_yield settlement, a stable system digest, and a refused non-human create with no published skill, addressing the previous review’s requested production path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Subagent completion changes the parent’s tool directory and unnecessarily invalidates provider prompt reuse.
Reason: The change repairs a documented prompt-stability invariant while retaining the intentional human-only personal-library boundary.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR addresses a current prompt-stability bug without granting non-human library access; no actionable introduced defect was found, and current-head maintainer security approval remains required.

Priority: P2
Reviewed head: f2a8a222d00e92a866c5be058cc0cf3336e36f93

Before merge

  • Await maintainer action - A maintainer must review the security-sensitive change and approve head f2a8a22 with /allow-security-sensitive-change.

Findings

None.

Tests

  • Missing end-to-end proof: A base-failing/head-passing execution of the added regression is not supplied; steer-specific live execution is explicitly outside the supplied Gateway scenario.
Agent review details

How this fits together

Gateway turn preparation supplies the library capability to agent tool assembly, which builds the model-facing directory and routes library calls to the existing authorization owner.

flowchart TD
  A[Gateway turn ingress] --> B[Skill library preparation]
  B --> C[Remembered session presentation]
  C --> D[Agent tool directory]
  D --> E[Provider prompt]
  D --> F[Library invocation]
  F --> G[Human authority or nonhuman refusal]
Loading

Technical review

Best possible solution:

Keep the session’s library presentation stable through the existing preparation owner while preserving current-turn execution authorization.

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

Current main shows the non-human capability omission reaching conditional tool registration, and the linked report supplies a matching live cache trace; no target code was executed during this review.

Is this the best way to solve the issue?

The focused repair follows the documented presentation-versus-authority contract and avoids persisting capabilities; its bounded memory retains presentation only within the Gateway process.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4e2b4efa547b.

Provenance checked

  • Non-human skill-library advertising changes intended behavior with a stated reason (75bcd26: Personal libraries required attributed human ingress and run-bound authority; later tool separation made library advertising conditional on that capability.)
  • Prepared human authority and session preparation keeps the original intent (baff85b: Combine selection and authoring preparation to reduce repeated SQLite work while retaining requester and permission checks.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +52, Tests +34. Total +86 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 55 3 +52
Tests 1 35 1 +34
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 90 4 +86

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #195328
Summary: The linked issue owns the specific capability-dependent directory churn, and another open PR proposes an alternative repair.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Avoidable prompt-prefix changes increase inference cost and latency during otherwise functioning subagent workflows.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-08T19:37:02.808Z sha 6c82829 :: needs real behavior proof before merge. :: none

Reviewed November 8, 2026, 3:14 PM ET / 20:14 UTC (Revision 2).

A settle client is not the attributed user, so looking up authoring
from that client still dropped the tool and changed the parent prompt.
Remember the last human shape for the session and refuse the call.

Signed-off-by: Sebastien Tardif <[email protected]>
@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The settle client is not the attributed user, so the directory entry is now the session's last human shape. Live Gateway proof is in the pull body: human skill_library list succeeded, the settle run kept the same system digest, and the create returned FORBIDDEN without writing a skill.

@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 8, 2026

This branch has not been deployed

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

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-review-required security-sensitive-changed size: S status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subagent announce/settle runs drop skill_library from the deferred tool directory, breaking the parent's prompt cache

1 participant