Session 27 of Going Meta, broadcast on April 2, 2024, introduces the reflection agent pattern as applied to knowledge graph construction. Jesus Barrasa builds a multi-actor LangGraph workflow where three GPT-4-powered agents collaborate in a loop: a Modelling Expert generates an entity-relationship model from a dataset description, a Model Reviewer critiques it, and a Model Editor applies the suggested changes — with the loop repeating until the model converges. The result is a self-improving KG construction pipeline that produces higher-quality graph schemas than a single LLM call.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jbarrasa/goingmeta/llms.txt
Use this file to discover all available pages before exploring further.
What You’ll Learn
- How to define three specialised LLM actors (Generator, Critic, Editor) using LangChain prompt templates
- How to wire them together into a LangGraph
MessageGraphwith conditional edges - How to use Kaggle’s Croissant metadata to automatically describe datasets for prompting
- How to implement both automated iteration and human-in-the-loop feedback modes
- How to visualise each iteration’s data model with Graphviz
The Three-Actor Architecture
Actor 1: Modelling Expert
Generates an entity-relationship model from dataset features. Outputs JSON with entities, relationships, attributes, and schema.org term mappings.
Actor 2: Model Reviewer
Critiques the generated model. Suggests up to 2-3 concise changes — detecting over/under-normalisation, suggesting better names — without rewriting the model itself.
Actor 3: Model Editor
Applies only the reviewer’s suggested changes to the current model and returns the updated JSON. Makes no changes beyond what it was instructed.
LangGraph Orchestrator
A
MessageGraph wires the three actors into a loop. Conditional edges determine whether to iterate further or stop, based on message count or human feedback.LangGraph StateGraph Pattern
The core of the session is the LangGraphMessageGraph that connects the three actors:
human_in_the_loop_agent = False runs fully automated iterations. Set it to True to replace the LLM critic with a human reviewer who types feedback at the prompt — useful for steering the model toward domain-specific requirements.Prompts for Each Actor
Modelling Expert Prompt
Model Reviewer Prompt
Running the Agent
The graph is invoked asynchronously over a dataset description. Here it runs over a crime dataset from Kaggle:event[END] contains the refined model, which can be visualised with Graphviz:
Iteration Dynamics
Automated Stopping Criterion
In automated mode, the agent stops after
len(state) < 6 — approximately two full generate-reflect-change cycles. This is configurable for your use case.Human-in-the-Loop Mode
In human-in-the-loop mode, the loop continues as long as the human provides non-empty feedback. An empty input terminates the loop, giving the human full control over convergence.
Graphviz Visualisation
After each iteration, the model is rendered to a PNG diagram using Graphviz’s
Digraph, letting you watch the data model evolve across iterations.Schema.org Alignment
Each entity, attribute, and relationship is annotated with the closest schema.org URI — grounding the generated model in a shared, machine-readable vocabulary.
Resources
Watch the Recording
Full session recording on YouTube — April 2, 2024.
Session Code (Colab)
LangGraph notebook and resources on GitHub.