Logo von Structured Output Contract Designer

Structured Output Contract Designer

Community
AnthonyAlcaraz
structured-output-contract-designer

Design the OUTPUT CONTRACT for a graph-agent node's seam, per Ch5 "Structured Generation: The Keystone of Reliable Communication" (Outlines). Most graph-agent failures are internode COMMUNICATION breakdowns, not bad reasoning — a node that emits free text is unreliable exactly where its output feeds the next node or a graph write. The designer picks an enforcement level (FREE_TEXT / JSON_SCHEMA / GRAMMAR_CONSTRAINED), emits a minimal contract for common DevOps-investigation node types, and validates a payload against that contract deterministically — the primitive that makes a seam verifiable. Use when wiring a node's output into another node, a graph write, or a tool call and free text would make the seam fragile. NOT for choosing WHICH pipeline shape to run (that is pipeline selection), NOT for terminal human-facing prose with no downstream parser, NOT for picking a model or a graph model class.

Übersicht

HerausgeberAnthonyAlcaraz
Repositoryagentic-graph-rag-skills
Skill-Namestructured-output-contract-designer
Sterne
29
Forks
9
Mitgelieferte Dateien
2
LizenzMIT
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.

  • Mitgelieferte Dateien: 2

    Skripte, Vorlagen und Referenzmaterial, die das Modell bei der Arbeit lesen kann. Die Dateien sind schreibgeschützt und werden niemals ausgeführt.

  • Open Source

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

Installation

Installieren Sie den KI-Skill Structured Output Contract Designer 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/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/reasoning-planning/structured-output-contract-designer
  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/AnthonyAlcaraz/agentic-graph-rag-skills.git /tmp/agentic-graph-rag-skills
mkdir -p .claude/skills
cp -r /tmp/agentic-graph-rag-skills/skills/reasoning-planning/structured-output-contract-designer .claude/skills/structured-output-contract-designer
Starten Sie Claude Code nach dem Kopieren neu, damit der neue Skill erkannt wird.

In TypingMind verwenden

Aktivieren Sie Structured Output Contract Designer 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 Structured Output Contract Designer 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 Structured Output Contract Designer 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.

Structured Output Contract Designer

Overview

After the graph architecture is in place, one failure dominates production: even with perfect reasoning and validated retrieval, the system collapses when nodes cannot parse each other's outputs. The chapter is blunt — most graph-agent failures are internode COMMUNICATION breakdowns, not bad reasoning. A workflow graph is useless when output formats vary unpredictably.

Structured output is the keystone that fixes this. Instead of hoping a node produces a parseable format, you constrain generation so producing anything else is impossible. Outlines builds a finite-state machine over the valid token sequences of your schema/grammar and zeros out any token that would leave the valid set, so the output is valid by construction, not by post-hoc validation that can be bypassed or fail silently.

The designer chooses an enforcement level per node seam:

  • FREE_TEXT — terminal, human-facing prose with no downstream parser. A schema would only add latency. Admissible only when the reader is human and the output is not reliability-critical.
  • JSON_SCHEMA — the default for any machine seam: node-to-node hand-off, a graph write, or a tool call. The next node relies on the shape instead of defensively parsing prose.
  • GRAMMAR_CONSTRAINED — the output must match a formal grammar, draw from a closed vocabulary, or land on a specific graph node-type. The grammar makes every out-of-vocabulary / off-type sequence physically ungenerable.

It also emits minimal contracts for common DevOps-investigation node types (hypothesis, remediation, reasoning, validation) and validates a payload against a contract deterministically — required fields present, types match, closed vocabularies honored. That validation is the concrete form of the chapter's claim that structured output makes the seam verifiable. Because structure compounds with the graph, this same primitive carries into Ch6, where grammar-constrained decoding makes MCP tool calls syntactically valid too.

When to Use

  • Wiring a node's output into another node, a graph write, or a tool call
  • Deciding whether a node's output needs a schema or a grammar, or can stay prose
  • Designing the contract for a hypothesis / remediation / reasoning / validation node
  • Justifying "this seam is reliable by construction" in a design doc

Phrases: "structured output", "output contract", "constrained decoding", "Outlines schema", "grammar-constrained", "node output format", "internode contract", "make this seam parseable".

When NOT to Use

  • Choosing which pipeline shape to run (sequential / tree / loop) — that is pipeline-architecture selection, a different axis.
  • Terminal human-facing prose. If the only reader is a human and nothing downstream parses it, a schema is latency for no reliability gain.
  • Picking a model or a graph model class. This designs the output contract at a seam, not the model behind it or the store under it.
  • A seam that already has an enforced contract. If the interface is fixed and validated upstream, adopt it.

Process

StepInputActionOutputVerification
1A node's seam NodeProfile (consumed_by, needs_valid_parse, fixed_vocabulary, reliability_criticality, latency_budget)lib.recommend_enforcement(profile){recommended, rationale, scores}machine seams >= JSON_SCHEMA; fixed vocabulary -> GRAMMAR_CONSTRAINED; FREE_TEXT only for non-critical human output
2A node-type namelib.schema_from_node_type(node_type)contract dict {node_type, required, types, enums}required fields + types present; enum'd fields carry a closed vocabulary
3A payload + a contractlib.validate_against_contract(payload, contract){valid, violations}catches missing field, type mismatch, vocabulary violation; clean payload -> valid
4before/after parse rateslib.reliability_gain(free, constrained)seam delta + failures eliminated / million99.9% -> 100% eliminates 1000 failures / million

Rationalizations

Agent rationalizationDocumented rebuttal
"The model almost always returns valid JSON, so a plain prompt is fine.""Almost always" is the failure. At scale even a 0.1% malformed rate is real exposure (the insurance-claims example). Constrained decoding drives the malformed rate to zero — valid by construction, not by hoping.
"I'll validate the output after generation and retry on failure."Post-hoc validation can be bypassed or fail silently, and retry loops cost latency. Outlines makes the invalid output ungenerable, so every generation succeeds on the first attempt — no retry loop exists to bypass.
"This node just talks to a human, give it a schema anyway to be safe."FREE_TEXT is correct for a terminal human reader with no downstream parser. A schema there is latency for no reliability gain. The level must match the seam: prose for humans, schema/grammar for machines.
"A JSON schema is enough for a field that must be one of a fixed set."A schema can type the field as a string but not forbid an out-of-vocabulary value at the token level. A closed vocabulary / node-type target needs GRAMMAR_CONSTRAINED so the wrong token is never emitted.
"Structured output is just formatting, it doesn't affect reasoning."It is what makes reasoning composable: when each node can rely absolutely on its inputs' shape, it spends capacity on reasoning instead of defensive parsing. The contract carries the reliability of the whole graph, and it carries into Ch6 tool calls.

Red Flags

  • A node-to-node or graph-write seam recommended FREE_TEXT. The profile is wrong — a machine seam is not a human terminal reader. Re-check consumed_by.
  • GRAMMAR_CONSTRAINED chosen but no closed vocabulary or node-type exists. You are paying grammar cost for a plain structured hand-off; JSON_SCHEMA suffices unless a formal grammar is genuinely required.
  • validate_against_contract returns valid on a payload missing a required field. The contract's required list drifted from the node type — the seam is not actually verified.
  • Every node routes to the same enforcement level. The seam profiles are not discriminating; a terminal human summary and a graph-write node should not share a level.

Non-Negotiable Verification

  1. Run the benchmark battery. python cli.py benchmark must report 11/11:
    • graph-write / next-node / tool-call seams route to JSON_SCHEMA or stricter
    • a fixed vocabulary / node-type target routes to GRAMMAR_CONSTRAINED
    • FREE_TEXT only for a non-critical human terminal reader; a critical human seam is not FREE_TEXT
    • validation catches a missing required field, a type mismatch, and a closed-vocabulary violation; a well-formed payload validates clean
    • reliability_gain reports the correct seam delta
  2. Run the scenario. python cli.py scenario shows a hypothesis node's hand-off: the recommended enforcement, the contract, a passing and a failing payload, and the reliability delta from constraining the seam.
  3. Verify CLI help. python cli.py --help exits 0 and prints this SKILL.md description (so any harness can discover the skill from --help).

Security Posture

  • Prompt injection. Seam profiles and payloads are untrusted input handled as data - validation is deterministic key/type/enum checking, nothing is executed. Note the limit: a contract constrains SHAPE, not content. A schema-valid payload can still carry injected text in its string fields; contract validation is not sanitization.
  • Data exfiltration. No network calls, no file writes. Payloads under validation stay in-process and appear only in the stdout violations report the caller owns.
  • Privilege escalation. No shell invocation, no eval. Contracts are a security boundary: a closed vocabulary bounds what a node can emit into a tool call or graph write, so loosening an enum or dropping a required field widens the downstream attack surface - treat contract edits as privileged changes.

Source Attribution

Distilled from Agentic GraphRAG (O'Reilly, by Anthony Alcaraz and Sam Julien) Ch5 — Reasoning & Planning, section "Structured Generation: The Keystone of Reliable Communication". The constrained-decoding mechanism (a finite-state machine over valid token sequences that zeros out invalid tokens) is the Outlines library; the insurance-claims example (enumerated determination, non-negative amount, pattern-matched explanation code, mandatory appeal-rights language, valid by construction) is the chapter's real-world impact case. Structured output is a cross-chapter pillar: Ch5 constrains node output, and Ch6 applies the same grammar-constrained decoding to MCP tool calls so the seam is reliable on both sides.

Mitgelieferte Dateien

Das Modell liest diese Dateien bei Bedarf, während der Skill geladen ist. Sie werden als lesbare Dateien bereitgestellt und niemals ausgeführt.

Häufig gestellte Fragen

Was macht der KI-Skill Structured Output Contract Designer?

Design the OUTPUT CONTRACT for a graph-agent node's seam, per Ch5 "Structured Generation: The Keystone of Reliable Communication" (Outlines). Most graph-agent failures are internode COMMUNICATION breakdowns, not bad reasoning — a node that emits free text is unreliable exactly where its output feeds the next node or a graph write. The designer picks an enforcement level (FREE_TEXT / JSON_SCHEMA / GRAMMAR_CONSTRAINED), emits a minimal contract for common DevOps-investigation node types, and validates a payload against that contract deterministically — the primitive that makes a seam verifiab...

Warum Structured Output Contract Designer in TypingMind nutzen?

Weil Sie den Skill einmal installieren und mit jedem Modell verwenden können. Structured Output Contract Designer 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 Structured Output Contract Designer in TypingMind?

Öffnen Sie in TypingMind Plugins → Skills → Von GitHub installieren und fügen Sie https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/reasoning-planning/structured-output-contract-designer ein. TypingMind liest die Datei SKILL.md, bündelt die zugehörigen Dateien und installiert alles als Skill, den Sie für jeden Chat einzeln aktivieren können.

Welche KI-Modelle können Structured Output Contract Designer 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 Structured Output Contract Designer verwenden?

So viele Sie möchten. In TypingMind können Sie Structured Output Contract Designer 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 Structured Output Contract Designer kostenlos?

Ja. Der Skill wird von AnthonyAlcaraz auf GitHub unter der Lizenz MIT veröffentlicht. 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 👇