ai-bot: loadSkill — pull a skill's instructions on demand#5344
Draft
jurgenwerk wants to merge 3 commits into
Draft
ai-bot: loadSkill — pull a skill's instructions on demand#5344jurgenwerk wants to merge 3 commits into
jurgenwerk wants to merge 3 commits into
Conversation
First slice of the pull-model loadSkill tool (CS-11554): the bot-side core that fetches a skill's instructions on demand. - lib/load-skill.ts: the `loadSkill` tool schema the model will be offered, plus `executeLoadSkill` — mints a delegated, user-scoped realm token (CS-11553) and GETs skills/<name>/SKILL.md (or references/<path>) as raw source. Read-only and scoped to the requesting human, so the bot can't read anything they couldn't. Never throws; returns an ok/error result the caller hands back to the model. - tests/load-skill-test.ts: URL building, token minting, success, 404, and the disabled / forbidden delegation paths. Not yet wired into the response loop (advertise the tool + intercept the call + feed the result back to the model) — that lands next in this ticket; see the PR description. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Describe what the loadSkill module does as timeless fact rather than citing issue identifiers, per the evergreen-comments convention. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Make loadSkill a real, bot-executed tool instead of just a building block: - getResponse offers loadSkill whenever delegated realm sessions are configured (gated on the manager being enabled), and accepts a messages override so a turn can be re-run with tool results appended. - response-state drops loadSkill from the emitted command requests, so it is never handed to the host to execute (the bot runs it itself). - main.ts runs the generation as a bounded loop: when a round's only tool calls are loadSkill, fetch the skills and generate again with the results in context, up to LOAD_SKILL_MAX_ROUNDS; cost is summed across rounds and the response is finalized once. - load-skill-loop.ts holds the pure decision (buildLoadSkillFollowup) with tests; the whole path is inert unless AI_BOT_DELEGATION_SECRET is set, so behavior is unchanged where delegation is off. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Written by Claude on Matic's behalf.)
Draft — wired end to end and unit-tested, but not yet tried against a live model, and gated off until the delegation secret is set.
This adds
loadSkill. Instead of stuffing every enabled skill's full text into the prompt, the bot pulls a skill's instructions on demand, only when it needs them. It runs in the bot: it gets a short-lived, read-only token scoped to the person in the room and fetches the file straight from their realm over HTTP. So the bot can only read what that person could read, and it always gets the live version.How it works
loadSkilltool (args:realm,name, optionalpath) whenever delegation is configured.skills/<name>/SKILL.md, or a file underreferences/withpath— and feeds the content back, then keeps generating. It's the first tool the bot executes itself rather than handing to the host, so the generation step is now a small loop: load skills the model asked for, then answer (bounded so it can't spin).Safety
AI_BOT_DELEGATION_SECRETthe tool isn't offered and the loop never runs, so behavior is unchanged where delegation is off (everywhere today). The existing push path (skills pushed into the prompt) is untouched.Tests
load-skill-test.ts(the fetch/executor) andload-skill-loop-test.ts(the load-then-answer decision): 14 tests, all green; lint and types clean; the existing responder suite still passes.Follow-up (separate): refuse delegation in rooms with more than one human, so "the person in the room" is unambiguous.
🤖 Generated with Claude Code