Koragraph

Everything under an AI coding agent, from first principles.

A first-principles map of everything under an AI coding agent: how source code is parsed into a syntax tree, how a code knowledge graph is built from it, how large language models read, how agents retrieve context over MCP, and how Koragraph ties it together. Forty concepts, each explained on its own, drawn as one graph you can walk.

Code, parsedStructure, mappedMachines that read languageRetrieval and agentsKoragraph's stack

Code, parsed

What a codebase actually is, and how a machine turns flat text back into structure it can reason about.

Structure, mapped

Once you have the structure, you can draw the relationships. Nodes, edges, and the questions only a graph can answer.

Machines that read language

What a large language model is from the ground up: tokens, embeddings, attention, the context window, and where it goes wrong.

What a large language model is

A large language model is a function that, given some text, predicts the next token, trained on so much text that doing this well requires it to model a great deal about the world.

Tokens and tokenization

A token is the unit a model actually reads, a fragment of text between a character and a word, and tokenization is the reversible way text is chopped into them.

Embeddings and vector space

An embedding is a list of numbers that places a piece of text at a point in space, positioned so that things close in meaning sit close together.

The transformer and attention

The transformer is the architecture behind modern language models, and attention is its central trick: letting every token look at every other token to decide what matters.

The context window

The context window is the fixed amount of text a model can consider at once, and it is a budget to be spent well rather than a container to be filled.

Training and inference

Training is the slow, expensive process of fitting a model to data once, and inference is the fast, repeated process of using it, and confusing the two explains most misunderstandings about what a model can know.

Hallucination and grounding

A model hallucinates when it produces fluent text that is not true, and grounding is the practice of feeding it real facts so its answer is anchored to something checkable.

Prompt and context engineering

Prompt engineering is wording the request well, and context engineering is the larger discipline of deciding what information the model gets to see at all.

Retrieval and agents

How a model is turned into something that acts: retrieval, tools, planning, and memory that survives the conversation.

Retrieval-augmented generation

Retrieval-augmented generation is the pattern of looking up relevant information and putting it in the context window before the model answers, so the answer rests on fetched facts.

Vector search and similarity

Vector search finds text by nearness in embedding space rather than by matching words, which is powerful for prose and quietly wrong for code, where the caller and the callee rarely share vocabulary.

GraphRAG for code

GraphRAG for code is retrieval that walks a graph of the codebase to assemble context, following real edges out from a node instead of returning the chunks that scored highest for similarity.

What an AI agent is

An AI agent is a language model placed in a loop where it can take actions, see the results, and decide what to do next, which is what turns a text generator into something that gets work done.

Tool use and function calling

Tool use is the mechanism by which a model asks for an action to be performed, a search to be run or a function to be called, and receives the result back as text it can reason over.

Reasoning and planning

Reasoning is a model working through a problem in steps before answering, and planning is it deciding a sequence of actions, both of which improve sharply when the model is given the right facts to reason over.

Agentic coding

Agentic coding is letting an agent read, write and run code in a loop, which shifts the bottleneck from typing to giving the agent an accurate picture of the system it is editing.

Memory for agents

Memory is what lets an agent keep a fact past the end of a conversation, so a lesson learned once, a fix that worked, a hazard, does not have to be rediscovered on every session.

Koragraph's stack

The protocol, the local store, the ingest pipeline, and the reasons a resolved graph beats text search for code.

The Model Context Protocol

The Model Context Protocol is an open standard that lets any AI model reach any external tool or data source through one common interface, so a data source is built once and every client can use it.

MCP servers and clients

In MCP the agent is the client and the thing it reaches is the server, and a local server is the right shape whenever the data, such as your source code, should never leave the machine.

Tools, resources and prompts

An MCP server offers three things: tools the agent can call, resources it can read, and prompts it can reuse, and most of the useful surface of a code server is its tools.

Local-first, offline by design

A local-first tool does its work on your own machine with no cloud round trip, which for source code is not a feature but a requirement, and it also happens to be faster and to work on a plane.

SQLite as the store

SQLite is a full relational database that lives in a single file with no server, which makes it the natural home for a code graph that has to persist on your machine across sessions and follow renames.

The ingest pipeline

Ingest is the pass that turns a pile of repositories into one graph: parse with tree-sitter, extract declarations, resolve every edge, mine the git history, and write it all to the local store.

Graph vs grep vs embeddings

Text search finds strings that look alike and vector search finds text that means something similar, but only a resolved graph can answer what is actually connected to what, which is the question code work turns on.

The context layer

A context layer sits between your codebase and your agent and decides what the agent sees for a given question, which is the job Koragraph exists to do and the point every other concept here builds toward.