LLMs are generalists. Regardless if they’re foundation models, instruct models or thinking models, there’s a limit to what they can do in terms of specialized work.

How do we work around that limitation and turn a generalist LLM to a reliable specialist for a given set of tasks?

RAG and RLM virtually expand the context window while SKILL and MCP enable external tool access.

This post describes each technique, implementation/usage mechanics, cons/pros, and tips on when to use or avoid it.

Disclosure: some AI is used in the early research and draft stage of this this page, but I’ve gone through everything multiple times and edited heavily to ensure that it represents my own thoughts and experience.

1. RAG

Retrieval-Augmented Generation

At its core, RAG is the AI equivalent of Just-In-Time (JIT) dependency injection. LLM’s weights are static after training. What if we want to add proprietary or up to date information to it?

RAG introduces an external lookup mechanism that executes before the user prompt is submitted to the model. The goal is to dynamically append highly relevant, specialized knowledge directly into the execution context.

Implementing RAG

Before RAG can be used, the knowledge base must be prepared and indexed into a searchable format.

  1. Ingestion: Raw domain data (documents, wikis, logs) is collected and parsed.

  2. Chunking: Text is split into smaller, semantically meaningful segments to fit within embedding and context window limits.

  3. Embedding: An embedding model converts the text chunks into high-dimensional vector representations (basically a numerical array).

  4. Storage: The vectors and their corresponding text chunks are saved in a vector database for rapid similarity search like SQLite-Vector, Postgress pgvector, Pinecone or just a simple array that’s loaded from JSON.

Using RAG

When a user interacts with the system, the pre-built vector database is queried to inject context dynamically.

  1. Retrieval: The user’s query is intercepted and converted into a vector using the same embedding model.

  2. Search: The system performs a similarity search (e.g., cosine similarity) in the vector database to find the most relevant chunks.

  3. Injection: The retrieved text is prepended or appended to the user’s prompt as context.

  4. Generation: The LLM processes the augmented prompt to generate an informed response.

Pros and Cons of RAG

RAG Use case

Note: if the size of the dataset is small, you can skip the embedding and vector DB by directly including it to the system prompt. This method is called CAG (Cache-Augmented Retrieval) but due to simplicity and limited application I didn’t include it in the list.

See also

2. SKILL

Dynamic Capability Loading

If RAG is like Just-In-Time dependency injection, SKILL operates like Dynamic Link Libraries (DLLs).

SKILL reverses the RAG flow: instead of a rigid vector search blindly injecting data, the LLM itself decides what capabilities it needs to acquire based on the context of the conversation.

This also eliminates the need for the embedding model and vector DB, making it much easier to use.

Implementing SKILL

SME (subject matter experts) must first define the skills, write the deterministic code, and iteratively evaluate the LLM’s routing behavior before deployment.

  1. Definition: Engineers write clear, concise descriptions of specific capabilities (e.g., “Financial Calculator”, “User Authentication Manager”).

  2. Scripting: Deterministic code scripts (e.g., Node.js or Python functions) are written to handle tasks that LLMs are bad at, like math or precise string formatting.

  3. Evaluation (Eval Loop): The skill is tested against a “golden dataset” of test queries. The evaluation framework checks if the LLM correctly routes to the new skill and if the tool returns the expected output. Failures trigger refinements to the skill description or the underlying scripts.

  4. Registration: Once the skill passes the evaluation threshold, the skill descriptions, manuals, and executable scripts are registered in a central Skill Registry (e.g. Anthropic’s) accessible to the AI applications.

Using SKILL

Each SKILL has has a name and description field.

  1. Capability Broadcasting: The system prompt is injected with a lightweight list of available skill summaries (their name and description).

  2. Evaluation: The LLM evaluates the user prompt against its known capabilities.

  3. Retrieval: If needed, the LLM requests to load the specific full skill manual or script it requires to solve the problem.

  4. Augmentation & Tooling: The system loads the requested skill. Optionally, the LLM makes tool calls based on the deterministic scripts offered by the skill (the orchestrator executes those calls).

  5. Execution: The LLM uses the results of the tool execution and the newly loaded context to formulate a highly specialized answer.

Pros and Cons of SKILL

SKILL Use case

See also

3. MCP

Model Context Protocol

MCP is the POSIX standard or API Gateway for AI. Originally created to standardize how LLMs interact with external software (browsers, IDEs, databases, SaaS), MCP defines a strict client-server architecture. It exposes three core primitives:

✳️ You may notice that MCP has prompt and tools in common with SKILLS. Although MCP was originally introduced as a translation layer, many MCPs are self-contained, composed of a prompt and tool. For those cases it’s better to use SKILLs.

Implementing MCP

The MCP server acts as an integration layer that must be configured to talk to external systems and rigorously tested for translation accuracy.

  1. Server Setup: An MCP server instance is provisioned on the network or locally. This can be as simple as a docker container or even an npx command.

  2. Configuration: Engineers define the Resources (e.g., file paths, database schemas) and Tools (e.g., API POST requests) the server will expose.

  3. Authentication & Routing: The server is configured with the necessary credentials and network routes to securely communicate with the target external systems. MCP server acts as an OAuth 2.1 resource server and MCP client acts as an OAuth 2.1 client.

  4. Integration Evaluation (Eval Loop): Automated test suites prompt an LLM to interact with the newly configured MCP server. The Eval framework validates that the LLM correctly discovers tools, forms valid JSON-RPC requests, and that the target API responds accurately without unintended state changes.

Using MCP

The LLM client establishes a standardized connection to interact with the environment.

  1. Discovery: The LLM client (not the raw LLM) connects to the MCP server and queries its available Prompts, Resources, and Tools via standardized JSON-RPC.

  2. Integration: The LLM reads a Resource (e.g., pulling a GitHub issue) or invokes a Tool (e.g., triggering a build pipeline). The LLM client makes the call.

  3. Translation: The MCP server translates the standardized LLM JSON-RPC request into the proprietary API calls of the target software.

  4. Callback: The external software executes the action and returns the result through the MCP server back to the LLM Client which will be handed to the LLM.

Pros and Cons of MCP

MCP Use case

See also

4. RLM

Recursive Language Models

If SKILL operates like DLLs, RLM is like FFI (foreign function interface).

RLM is the newest architectural evolution, functioning similarly to MapReduce combined with a recursive REPL (Read-Eval-Print Loop) like the one you find in Python or Node.js.

Its primary goal is to entirely bypass the physical constraints of the LLM context window. Instead of trying to stuff a massive prompt into the model, RLM treats the long prompt as an external environment variable.

Implementing RLM

Because RLM executes code recursively against massive datasets, a secure execution environment must be prepared.

  1. Environment Provisioning: A sandboxed REPL environment (e.g., a Docker container or Firecracker microVM) is set up with necessary runtimes (Python, Node.js, etc.).

  2. Data Staging: The massive dataset (e.g., an entire repository or gigabytes of legal documents) is staged on a fast local filesystem.

  3. Variable Mounting: The dataset is mounted into the REPL environment as an accessible global variable or directory structure.

Using RLM

The LLM is given access into the secure environment to recursively explore the data.

  1. Scaffolding: The system prompt contains instructions explaining the REPL environment, its capabilities, and the overarching goal.

  2. Programmatic Peeking: The LLM writes code to peek into, search, or slice the massive variable mounted in the environment.

  3. Recursive Invocation: The LLM writes programs that recursively spawn new instances of itself to process the sliced snippets of the prompt/data in parallel.

  4. Aggregation: The recursive calls collapse back up the stack, aggregating findings, and the final state/variable is returned to the user.

Pros and Cons of RLM

RLM Use case

If you found this post insightful pls share it in your circles and on social media to inspire others.

Share


My monetization strategy is to give away most content for free but these posts take anywhere from a few hours to a few days to draft, edit, research, illustrate, and publish. I pull these hours from my private time, vacation days and weekends. The simplest way to support this work is to like, subscribe and share it. If you really want to support me lifting our community, you can consider a paid subscription. If you want to save, you can get 20% off via this link. As a token of appreciation, subscribers get full access to the Pro-Tips sections and my online book Reliability Engineering Mindset. Your contribution also funds my open-source products like Service Level Calculator. You can also invite your friends to gain free access.

And to those of you who already support me: thank you for sponsoring this content for others. 🙌 If you have questions or feedback, or want me to dig deeper into something, please let me know in the comments.

Further reading