Repository navigation
adapters core: instructions.mjs, and the Claude adapter on the broker's rules - #173
Merged
Merged
Conversation
…'s rules Stage 1.2, step 1, part 2 (AIChat 4083). core/instructions.mjs fetches the rules every agent works by (GET /api/instructions, #172) and composes what a model is told: the rules, who the agent is, the adapter's short block on its runtime, notices, the owner's local rules last (they win). It returns the parts with their sources and versions too, for the agent manager. A broker without /api/instructions gets null and the adapter keeps its own text. The Claude adapter is the first on it: its block says only what is Claude Code's own (channel frames, to/room, attachments, links, games); how to behave comes from the broker. Older brokers get the instructions they got before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…says (its runtime) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 28, 2026
Merged
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.
Stage 1.2, step 1, part 2 (AIChat 4083). It builds on #172.
src/adapters/core/instructions.mjsis plain JS with no imports at all, likefiles.mjsandbroker.mjs, with types in.d.mts:fetchInstructions({httpBase, token, timeoutMs})readsGET /api/instructions. It returnsnullfor an old broker (404), no answer in time, no connection or a bad response. In that case the adapter keeps its own text.composeInstructions({fetched, runtime, notices, local, fallback})builds the text in this order:## How your runtime connects you to AIChatwith the adapter's block;## Local rules from your owner (they win…).It returns
{ text, parts }. Each part has its source (broker/fallback/adapter/local) and version, for the manager in the following PR, as codex-alexey asked (4031).4 tests (
instructions.test.mjs), added tonpm test.The Claude adapter is the first on it.
CLAUDE_RUNTIMEcontains only what is specific to Claude Code: the<channel>frame,tovsroom, attachments, links, game moves, and that the owner is the user of this session with CLAUDE.md as their local rules. Behaviour now comes from the broker's rules.PEER_RULEstays last, as before.PEER_RULE.MECHANICS+ self).LEGACY_INSTRUCTIONS, as before.AGENTS.md(section «Адаптери») says where rules go: behaviour goes in the broker's rules, and the adapter text describes only how its runtime differs.npm test: 341 pass, 0 fail.typecheckpasses.Next: agy (
systemPrompt.append) and OpenCode (.aichat/instructions.md+instructionsinopencode.jsonc), each in its own PR.🤖 Generated with Claude Code