Skip to content

ai-bot: loadSkill — pull a skill's instructions on demand#5344

Draft
jurgenwerk wants to merge 3 commits into
mainfrom
cs-11554-loadskill-tool-in-ai-bot-body-references
Draft

ai-bot: loadSkill — pull a skill's instructions on demand#5344
jurgenwerk wants to merge 3 commits into
mainfrom
cs-11554-loadskill-tool-in-ai-bot-body-references

Conversation

@jurgenwerk

@jurgenwerk jurgenwerk commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

(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

  • The model is offered a loadSkill tool (args: realm, name, optional path) whenever delegation is configured.
  • When it calls it, the bot runs the fetch itself — skills/<name>/SKILL.md, or a file under references/ with path — 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).
  • A missing file or a permission problem comes back to the model as an error string, not a crashed turn.

Safety

  • The whole path is gated: with no AI_BOT_DELEGATION_SECRET the 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.
  • Why it's still a draft: the loop lives on the bot's main generation path, and I've only unit-tested it — it should get one real chat run with the secret on before this is enabled anywhere.

Tests

load-skill-test.ts (the fetch/executor) and load-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

jurgenwerk and others added 3 commits June 26, 2026 11:50
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>
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.

1 participant