# From LLM Theory to Practical Agentic Implementations - Seth Juarez

## Executive summary

The talk demystifies Large Language Models (LLMs), arguing that their power does not come from inherent intelligence but from engineered 'harnesses' and fundamental primitives. The speaker outlines a progression of techniques—from simple completions to complex agentic loops—that allow developers to build robust, reliable AI systems by controlling the model's input context, output structure, and execution flow. Key concepts include using structured JSON for control flow, implementing tool calling via runtimes (not the LLM itself), establishing guardrails, and orchestrating multi-step workflows through shared 'threads.'

## Key takeaways

- LLMs are Next Token Predictors: At its core, an LLM is a giant mathematical function that predicts the next token based on input tokens. The perceived intelligence comes from the surrounding runtime logic (the harness), not the model itself.
- The Agentic Loop is the Core Primitive: True agency is achieved by implementing an 'agentic loop'—a while loop in the runtime that continuously checks for and executes tool calls, feeding the results back into the context until no more tools are needed. This is the fundamental unit of agency.
- Guardrails and Bindings Enhance Reliability: To prevent misuse or incorrect execution (e.g., unauthorized memory access), developers must implement guardrail functions in their runtime logic. Furthermore, 'bindings' allow injecting fixed parameters (like `user ID`) into function calls, removing the burden of context-dependent reasoning from the LLM.
- Composition Workflow for Multi-Step Agents: Complex tasks are solved by chaining multiple specialized agents or prompts (e.g., Research $ ightarrow$ Draft $ ightarrow$ Review). All these components share a single, persistent 'thread' context to maintain state and pass control flow sequentially.

## Technical details

- LLM Fundamentals: LMs operate by predicting the next token (a piece of a word) in hyperdimensional space. Training involves calculating a loss function by comparing the predicted probability distribution against the known correct answer, optimizing weights using calculus and backpropagation.
- Primitives Progression (Modes 1-9): The talk progresses through nine scenarios: simple completion $ ightarrow$ structured output (JSON for control flow) $ ightarrow$ chat context (`thread` object) $ ightarrow$ tool calling/function calling $ ightarrow$ agentic loop $ ightarrow$ guardrails $ ightarrow$ bindings $ ightarrow$ steering $ ightarrow$ composition workflow. Each step builds upon the last, increasing system complexity and reliability.
- Context Management: The 'thread' (or message array) is a critical data structure that maintains conversation history and state for the LLM. Context can be managed via caching layers to improve speed, but context window length remains an engineering constraint.
- Tool Calling Mechanism: The model suggests a function call by returning JSON structured like a function signature (e.g., `fetch(query)`). The actual execution is handled entirely by the external runtime, which parses the tool call and executes the corresponding bound function/delegate.

## Practical implications

- Build engineers can move beyond treating LLMs as simple chat interfaces and instead design robust, stateful systems by controlling the execution flow (the 'harness').
- Implementing agentic loops is crucial for creating reliable automation that requires multiple steps of decision-making and external action.
- Understanding context management (threads) and guardrails allows for building enterprise-grade AI solutions with predictable failure modes and controlled access to resources.

## Topics

Large Language Models (LLMs), Agentic Systems, Prompt Engineering, Tool Calling, State Management, Software Architecture, Prompty, Seth Juarez Draft Flow Repo

Source: https://www.youtube.com/watch?v=rYBAyvaF3Yo
