Logo von Composing Context

Composing Context

Organisation
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

Übersicht

Herausgeberfriday-platform
Repositoryfriday-studio
Skill-Namecomposing-context
Sterne
102
Forks
5
Mitgelieferte Dateien
Nur Anweisungen
Links
  • Anweisungen in Markdown

    Eine SKILL.md-Datei, die das Modell bei Bedarf lädt. So werden nur dann Token verbraucht, wenn eine Anfrage tatsächlich dazu passt.

  • Funktioniert mit jedem LLM

    KI-Skills bestehen aus reinem Markdown, nicht aus anbieterspezifischem Code. Daher funktionieren sie mit GPT, Claude, Gemini, Grok oder einem lokalen Modell.

  • In sich abgeschlossen

    Alles, was das Modell braucht, steht in den Anweisungen — keine zusätzlichen Dateien zum Synchronisieren.

  • Open Source

    Von friday-platform auf GitHub veröffentlicht. Prüfen Sie vor der Installation die Quelldateien.

Installation

Installieren Sie den KI-Skill Composing Context in TypingMind, um ihn mit jedem LLM zu nutzen, oder fügen Sie ihn einem anderen Agenten hinzu, der SKILL.md lesen kann.

1

In TypingMind installieren

TypingMind installiert einen Skill direkt aus seinem GitHub-Ordner. Dabei liest die App SKILL.md, bündelt die Ressourcendateien und speichert das Ergebnis lokal.

  1. Öffnen Sie die App und gehen Sie zu Plugins → Skills.
  2. Wählen Sie „Von GitHub installieren“.
  3. Fügen Sie die unten angegebene URL des Skill-Ordners ein und bestätigen Sie.
    https://github.com/friday-platform/friday-studio/tree/main/packages/system/skills/composing-context
  4. Aktivieren Sie den Skill in jedem Chat, in dem er verfügbar sein soll.
Plugins → Skills → Skill hinzufügen → Über GitHub-URL. Fügen Sie dann die Ordner-URL ein und klicken Sie auf „Weiter“.
2

In einem anderen Agenten installieren

Jeder Agent, der das Agent-Skills-Format unterstützt, kann diesen Skill nutzen. Kopieren Sie den Ordner in das Skill-Verzeichnis des jeweiligen Agenten.

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
Starten Sie Claude Code nach dem Kopieren neu, damit der neue Skill erkannt wird.

In TypingMind verwenden

Aktivieren Sie Composing Context in einem beliebigen Chat in TypingMind. Den Rest übernimmt das Modell. Name und Beschreibung des Skills stehen im System-Prompt. Sobald eine Anfrage passt, lädt das Modell selbstständig die vollständigen Anweisungen — Sie müssen den Skill nie manuell aufrufen, und er verbraucht erst Token, wenn er tatsächlich genutzt wird.

Das Modell lädt Composing Context automatisch, sobald eine passende Anfrage gestellt wird.

Funktioniert mit jedem KI-Modell

KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher ist Composing Context nicht an das Modell gebunden, für das der Skill geschrieben wurde. Installieren Sie ihn einmal in TypingMind und nutzen Sie ihn mit GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder einem selbst betriebenen lokalen Modell — alles mit Ihren eigenen API-Schlüsseln.

  • Wird nur bei Bedarf geladen

    Der System-Prompt enthält nur den Namen und die Beschreibung. Die Anweisungen werden bei der ersten passenden Anfrage geladen. Ein ungenutzter Skill verursacht daher keine Kosten.

  • Modell im laufenden Chat wechseln

    Da der Skill aus Anweisungen statt aus Code besteht, funktioniert er auch nach einem Modellwechsel — das nächste Modell liest dieselbe SKILL.md-Datei.

Skill-Anweisungen

Dies ist der Inhalt von SKILL.md, den das Modell lädt. Lesen Sie ihn vor der Installation — ein Skill besteht aus Anweisungen, denen Ihr Modell folgt.

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.

Häufig gestellte Fragen

Was macht der 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.

Warum Composing Context in TypingMind nutzen?

Weil Sie den Skill einmal installieren und mit jedem Modell verwenden können. Composing Context besteht aus reinem Markdown statt aus anbieterspezifischem Code. So funktioniert derselbe Skill mit GPT-5, Claude, Gemini, Grok oder einem lokalen Modell – und Sie können das Modell mitten im Chat wechseln, ohne dass der Skill seine Funktion verliert. TypingMind verwendet Ihre eigenen API-Schlüssel. Sie bezahlen die Anbieter daher direkt statt über ein Abonnement pro Nutzerplatz, und Ihre Skills und Chats bleiben in Ihrem eigenen Speicher.

Wie installiere ich Composing Context in TypingMind?

Öffnen Sie in TypingMind Plugins → Skills → Von GitHub installieren und fügen Sie https://github.com/friday-platform/friday-studio/tree/main/packages/system/skills/composing-context ein. TypingMind liest die Datei SKILL.md und installiert den Skill, den Sie für jeden Chat einzeln aktivieren können.

Welche KI-Modelle können Composing Context nutzen?

Jedes Modell, das Sie mit TypingMind verbinden. KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher können GPT, Claude, Gemini, Grok und lokale Modelle diesen Skill laden, wenn eine Anfrage dazu passt.

Wie viele KI-Modelle kann ich mit Composing Context verwenden?

So viele Sie möchten. In TypingMind können Sie Composing Context mit jedem Modell verwenden, das Skills unterstützt, etwa mit GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama. Dabei nutzen Sie Ihre eigenen API-Schlüssel.

Ist der KI-Skill Composing Context kostenlos?

Der Skill wird von friday-platform auf GitHub veröffentlicht. Prüfen Sie im Repository, ob dort Lizenzbedingungen angegeben sind. Sie bezahlen nur Ihren eigenen KI-Anbieter für die verwendeten Token.

Was sind KI-Skills?

Ein KI-Skill ist ein wiederverwendbares Anweisungspaket, das einem KI-Modell vermittelt, wie es eine bestimmte Aufgabe erledigt. Es folgt dem offenen Format Agent Skills: Die Datei SKILL.md enthält den Namen und die Beschreibung des Skills. Hinzu kommen bei Bedarf Skripte, Vorlagen oder Referenzdateien für das Modell. Das Modell liest die Anweisungen nur, wenn Ihre Anfrage zum Skill passt. Ein installierter Skill verursacht daher erst Kosten, wenn er verwendet wird.

Wie unterscheiden sich KI-Skills von Plugins oder MCP-Servern?

Ein Plugin oder MCP-Server stellt einem Modell neue aufrufbare Tools bereit – Code, der auf einem System ausgeführt wird und ein Ergebnis zurückgibt. Ein KI-Skill vermittelt dem Modell stattdessen Wissen und Vorgehensweisen: wie es eine Aufgabe angeht, welche Schritte es befolgt und wie eine gute Ausgabe aussieht. Skills bestehen aus reinem Markdown und kommen daher ohne Server, API-Schlüssel und Laufzeitumgebung aus. Sie funktionieren mit jedem Modell.

Alle anzeigen

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇