liveBook · Manning

Schema

As explained in Context Engineering

A schema is a formal specification of the permitted structure, fields, and constraints of data or outputs.

A schema specifies permitted data structure, fields, and constraints. In agent systems, it can keep application state consistent, define tool-call contracts, or give model outputs a repeatable shape. section 5.4.1 section 4.2.1

Schemas shape data at several boundaries:

  • State schemas specify fields such as message lists, task identifiers, and execution status; scratchpads can track subgoals and constraints. section 5.4.1
  • Tool schemas define typed parameters, expected outputs, and structured errors, making the tool definition a contract between model and code. section 4.2.1
  • RDF ontologies define entity and relationship types, hierarchies, and constraints; their annotations can also support retrieval and inference. section 3.3.1

Normalizing support tickets

A few labeled bug reports demonstrate a recurring output structure with fields such as title, category, priority, summary, and next step. The model then continues that pattern for a new report. section 6.6.1

Listing 6.3 Few-shot prompting in the ticket normalizer
"role": "user", #1
"content": "Bug report:\nThe mobile app crashes when I try to upload a
20 MB PDF. It worked yesterday."

"role": "assistant", #2
"content": json.dumps({
    "title": "Crash when uploading large PDF",
    "category": "file_upload",
    "priority": "high",
    "summary": "The mobile app crashes during PDF upload when the file
    is around 20 MB.",
    "next_step": "Investigate upload limits and crash logs for the
    mobile client.",
}, indent=2)

"role": "user",
"content": "Bug report:\nSearch results on the dashboard take a long time
to load, especially in the morning."

"role": "assistant",
"content": json.dumps({
    "title": "Slow dashboard search",
    "category": "performance",
    "priority": "medium",
    "summary": "Dashboard search becomes slow, with the issue being most
    visible during morning usage.",
    "next_step": "Check query latency, indexing, and peak-time load on
    the search service.",
}, indent=2)

"role": "user", #3
"content": f"Bug report:\n{report}\n\nReturn only JSON."

Inspect the repeated prompt-and-output pattern used to teach a stable support-ticket structure. section 6.6.1

How Context Engineering covers it

How deep it goes
Defines typed fields and constraints across state, tools, and ontologies, but does not detail schema validation mechanics.
Examples
Uses typed agent state, tool parameter and output contracts, RDF ontologies, and labeled examples for ticket normalization.
What you can do after
Apply it via TypedDict, Pydantic, or JSON Schema to structure state and specify tool inputs and outputs.
How it connects
Connects to typed data structures, JSON Schema, RDF, ontologies, and few-shot prompting.

Also explained in

Compare how 54 books explain schema →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Context Engineering. The section links point to the parts of the book it draws on.