Logo: Composing Context

Composing Context

Organisatioun
friday-platform
composing-context

Internal pattern guide for composing turn-local retrieval-gated context into a synthetic user-message preface. Documents the `composePreface` helper in `@atlas/core/agent-context/compose-preface`. Loaded by infrastructure code that assembles per-turn LLM input — not user-invocable.

Add to TypingMind

Iwwersiicht

Editeurfriday-platform
Repositoryfriday-studio
Skill-Nummcomposing-context
Stären
102
Forks
5
Matgeliwwert Dateien
Nëmmen Instruktiounen
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    friday-platform huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Composing Context an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/friday-platform/friday-studio/tree/main/packages/system/skills/composing-context
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/friday-platform/friday-studio.git /tmp/friday-studio
mkdir -p .claude/skills
cp -r /tmp/friday-studio/packages/system/skills/composing-context .claude/skills/composing-context
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Composing Context an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Composing Context automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Composing Context net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Composing turn-local context as a synthetic user-message preface

This skill documents the synthetic user-message preface pattern used by Friday's chat supervisor and FSM type: llm actions to surface turn-local retrieved content (artifacts, narrative memory, temporal facts, future on-demand retrieval) to the model.

Why a synthetic preface and not the system prompt

Per-turn data does not belong in the system prompt. Mixing turn-local bytes into the system prompt invalidates the cacheable prefix on every turn, defeats Anthropic's 4-breakpoint cache layout (blocks 1/2/3 + top-level), and pulls org-private bytes into a cache scope that may be shared across tenants.

The synthetic preface lives in the first user message of the conversation, wrapped in <retrieved_content> envelopes. The system prompt stays byte-stable across weeks (block 1), workspace life (block 2), and session (block 3); turn-local variation rides in the messages array where it doesn't poison the cacheable prefix.

The helper: composePreface

ts
import {
  composePreface,
  type PrefaceEntry,
} from "@atlas/core/agent-context/compose-preface";

const entries: PrefaceEntry[] = [
  {
    source: "user-authored",
    origin: "memory:workspace-stores",
    body: memoryBlocks.join("\n\n"),
    fetched_at: new Date().toISOString(),
  },
  {
    source: "user-authored",
    origin: "artifacts:session",
    body: artifactBlocks.join("\n\n"),
    fetched_at: new Date().toISOString(),
  },
];

const preface = composePreface(entries);
// "" when entries is empty — concatenate without conditional checks.

Field semantics:

FieldMaps toPurpose
sourceprovenance attrTrust tier or content key (user-authored, external, system-config, artifact:<id>, memory:<store>, web:<url>, …)
originorigin attrHost scope the bytes were fetched from (workspace:<wsId>/session:<sId>, memory:workspace-stores, …)
bodyenvelope bodyModel-facing text
fetched_atfetched_at attrISO timestamp; omit when freshness is not meaningful

The helper is positionally indifferent — the caller decides whether to prepend the result as a synthetic user message, append it, or place it elsewhere. The string is the deliverable; positioning is the caller's choice.

The body is defanged before rendering: any literal </retrieved_content> close tag inside the body is rewritten to <\/retrieved_content> so a hostile payload cannot escape the envelope and land in the instructions frame. This mirrors wrapRetrieved in @atlas/llm.

Three call patterns

1. Pre-load: chat supervisor builds Block 4 from current state

The chat supervisor pulls memory + artifacts + temporal facts at the start of each turn, composes the preface, and prepends it as a synthetic user message at message position 0. The preface is ephemeral — it is not persisted to ChatStorage, so it does not accumulate in the conversation across turns.

See packages/system/agents/workspace-chat/workspace-chat.agent.ts (block4Entries / block4Preface / messagesWithBlock4Preface).

2. FSM type: llm action: same shape, prepended to action prompt

The FSM action runtime mirrors the chat pattern: pull narrative memory (via composeMemoryBlocks) and session-bound artifacts (via composeArtifactEntries), compose with composePreface, and prepend to the action's contextPrompt. The structured-entry shape from composeArtifactEntries is designed to drop straight into composePreface without intermediate string mangling.

See packages/fsm-engine/fsm-engine.ts (the case "llm" action prompt assembly).

3. On-demand mid-turn retrieval (forward-looking)

A future tool (e.g. web_fetch, parse_artifact, mid-turn semantic search) can hand the freshly-retrieved entry list to composePreface and inject it inline using whatever shape the LLM provider supports for mid-stream context — the helper is positionally indifferent and shape-agnostic, so the new caller drops in without reshaping.

Rules for callers

  1. Build a list of PrefaceEntry records, not pre-rendered XML strings. The helper owns the rendering. Callers that already have pre-rendered envelopes (e.g. composeArtifactBlocks's legacy return shape) wrap them in a single PrefaceEntry rather than reformatting each one — see Block 4 in the chat supervisor for the canonical example.

  2. Set source to a trust tier or content key, not a generic label. The model's <retrieved_content_hygiene> rule keys off provenance to decide trust (user-authored / system-config are trusted; external is not). Use the conventions in @atlas/llm/retrieved-content.ts:ProvenanceSource when the source is a trust tier.

  3. Set origin to a parseable host:scope identifier. The model does not parse origin literally, but operators inspecting captured transcripts do. Conventions: workspace:<wsId>/session:<sId>, memory:<store>, web:<url>, fsm:<jobId>:input.

  4. Always set fetched_at when the body's freshness matters. Omit only for static content (e.g. system-config). Use the same timestamp for all entries assembled in one turn so operators can correlate them.

  5. Do not nest <retrieved_content> envelopes deliberately, except in the legacy chat-Block-4 wrap-of-wrapped pattern that exists for per-section grouping. The defang protects against accidental nesting; deliberate nesting creates confusing transcripts.

  6. Never persist the preface as part of a stored UI message. It is an ephemeral runtime artifact rebuilt from current state each turn. Persisting it accumulates stale snapshots in the conversation and defeats the point of having retrieval-gated content.

Heefeg gestallte Froen

Wat mécht de KI-Skill Composing Context?

Internal pattern guide for composing turn-local retrieval-gated context into a synthetic user-message preface. Documents the `composePreface` helper in `@atlas/core/agent-context/compose-preface`. Loaded by infrastructure code that assembles per-turn LLM input — not user-invocable.

Firwat Composing Context op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Composing Context besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Composing Context an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/friday-platform/friday-studio/tree/main/packages/system/skills/composing-context an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Composing Context benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Composing Context benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Composing Context domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Composing Context gratis?

friday-platform huet de Skill op GitHub publizéiert. Kuckt am Repository no de Lizenzbedéngungen. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇