<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: fcn06</title>
    <description>The latest articles on DEV Community by fcn06 (@fcn06).</description>
    <link>https://dev.to/fcn06</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4070178%2F49cf50bd-9c2a-40ed-a404-8ed0b8345aeb.png</url>
      <title>DEV Community: fcn06</title>
      <link>https://dev.to/fcn06</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fcn06"/>
    <language>en</language>
    <item>
      <title>Unifying Agent Orchestration and Model Gateways in Rust: Solving the Stateless Turn Problem</title>
      <dc:creator>fcn06</dc:creator>
      <pubDate>Wed, 09 Sep 2026 19:35:57 +0000</pubDate>
      <link>https://dev.to/fcn06/unifying-agent-orchestration-and-model-gateways-in-rust-solving-the-stateless-turn-problem-op2</link>
      <guid>https://dev.to/fcn06/unifying-agent-orchestration-and-model-gateways-in-rust-solving-the-stateless-turn-problem-op2</guid>
      <description>&lt;p&gt;While developing multi-agent systems and LLM integrations in Rust, I found myself repeatedly confronting two related architectural challenges.&lt;/p&gt;

&lt;p&gt;The first was an operational divide between two layers of infrastructure: a lightweight model gateway for routing and caching LLM requests, and an agent orchestration runtime responsible for tool execution, planning, and task resolution. Teams often end up deploying two separate systems for these workloads, duplicating provider configurations, authentication layers, and connection pools.&lt;/p&gt;

&lt;p&gt;The second challenge was the "stateless turn" problem: many agent loops initialize each execution turn from scratch (&lt;code&gt;[system_prompt, current_user_message]&lt;/code&gt;), immediately discarding previous tool outputs and conversational turns. While simple, this makes multi-turn reasoning brittle and deprives agents of contextual continuity.&lt;/p&gt;

&lt;p&gt;This article shares how we approached these challenges around a unified Tokio-based architecture, and how we recently implemented an opt-in, four-tier context engine to give agents persistent conversational memory without sacrificing backward compatibility.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Dual-Mode Architectural Pattern
&lt;/h2&gt;

&lt;p&gt;Instead of maintaining a separate proxy daemon and an agent orchestrator, the system is organized around two complementary operational modes sharing the same core runtime:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+--------------------------------------------------------------------------------------------------+
|                                        RUNTIME MODES                                             |
+--------------------------------------------------------------------------------------------------+
|                                                                                                  |
|   MODE 1: MULTI-AGENT &amp;amp; MCP ORCHESTRATION               MODE 2: MODEL GATEWAY SERVER             |
|   (kickstart/multi_agent_orchestration_kickstart/)      (kickstart/gateway_kickstart/)           |
|                                                                                                  |
|   • Planner Agent (Dynamic DAG generation)              • POST /v1/chat/completions (OpenAI API) |
|   • Executor Agent (Workflow DAG execution)             • POST /v1/responses (Open Responses)    |
|   • Domain Specialists with native MCP Tools            • Stateful multi-turn chaining           |
|   • Pluggable Context &amp;amp; Memory Services                 • Multi-provider routing (Groq, Gemini,  |
|   • Evaluation &amp;amp; Self-Correction (Judge)                  OpenAI, Ollama, vLLM, llama.cpp)       |
|   • Agent-to-Agent (A2A) protocol contracts             • High-throughput lock-free cache         |
|                                                                                                  |
+--------------------------------------------------------------------------------------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Mode 1: Agent Orchestration via Model Context Protocol (MCP)
&lt;/h3&gt;

&lt;p&gt;Mode 1 coordinates specialized agents through explicit message contracts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Planner Agent:&lt;/strong&gt; Analyzes high-level requests and constructs a directed acyclic graph (DAG) of tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Executor Agent:&lt;/strong&gt; Traverses the DAG, resolving dependencies and dispatching step execution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Domain Specialists:&lt;/strong&gt; Execute tools using the &lt;strong&gt;Model Context Protocol (MCP)&lt;/strong&gt;, handling tools over standard I/O, Server-Sent Events (SSE), or streamable HTTP transports.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evaluation Service:&lt;/strong&gt; An optional LLM-as-a-Judge validation step that assesses tool outputs and prompts the agent for correction if the result is malformed.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Request ──&amp;gt; Planner ──&amp;gt; Task DAG ──&amp;gt; Executor ──&amp;gt; Specialist Agent ──&amp;gt; MCP Tool ──&amp;gt; Evaluation ──&amp;gt; Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Mode 2: OpenAI-Compatible Model Gateway
&lt;/h3&gt;

&lt;p&gt;Mode 2 acts as a standard inference gateway:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;/v1/chat/completions&lt;/code&gt;:&lt;/strong&gt; Drop-in compatibility with existing OpenAI SDKs, IDE extensions, and client pipelines.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;/v1/responses&lt;/code&gt;:&lt;/strong&gt; Stateful chaining that correlates turns using explicit response IDs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unified Provider Routing:&lt;/strong&gt; TOML-configured routing across commercial APIs (Groq, Google Gemini, OpenAI) and local runtimes (Ollama, vLLM, llama.cpp).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sharing a runtime means both modes share the same connection pooling, HTTP client configuration, secret management, and tracing telemetry.&lt;/p&gt;

&lt;h3&gt;
  
  
  Two Deployment Patterns: Start Unified, Let Usage Decide
&lt;/h3&gt;

&lt;p&gt;To accommodate different operational requirements, we implemented two concrete deployment patterns:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;"Full Swarm" (Agents + MCP + Gateway):&lt;/strong&gt; Runs the entire orchestration stack — planner, DAG executor, domain specialists with MCP tool servers, and the model gateway — in a single unified deployment. This provides an end-to-end autonomous environment where agents talk to LLMs directly through the local gateway with zero network hops, sharing connection pools and in-process memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Gateway-Only Swarm":&lt;/strong&gt; Strips away agent orchestration and runs purely as a high-performance inference gateway. It handles &lt;code&gt;/v1/chat/completions&lt;/code&gt;, provider failover, caching, and stateful response chaining (&lt;code&gt;/v1/responses&lt;/code&gt;) for external client applications, developer tools, or existing third-party agent stacks.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The underlying philosophy is pragmatic: &lt;strong&gt;start unified, and let actual production usage patterns tell you if they should stay glued.&lt;/strong&gt; If your inference proxying traffic grows 100x faster than agent orchestration, or if security requirements dictate isolating live tool execution behind private networks while keeping the gateway at the ingress, the gateway can be peeled off into an independent service without modifying client contracts or configuration formats.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem with Stateless Agent Loops
&lt;/h2&gt;

&lt;p&gt;During early iterations, our MCP agent loop followed a common pattern:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// A common pattern in basic agent runtimes&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;messages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nd"&gt;vec!&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="n"&gt;Message&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"system"&lt;/span&gt;&lt;span class="nf"&gt;.to_string&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;system_prompt&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="n"&gt;user_message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every user interaction started with a fresh message array. While clean and deterministic for single-shot question answering, this architecture has distinct failure modes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Session Amnesia:&lt;/strong&gt; Follow-up questions fail because prior exchanges and tool outputs vanish once the request terminates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write-Only Logging:&lt;/strong&gt; Memory traits are frequently defined with only a &lt;code&gt;log()&lt;/code&gt; method, recording conversation logs for telemetry while providing no retrieval mechanism back to the agent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt Coupling:&lt;/strong&gt; Ad-hoc attempts to inject history often result in manual string concatenation in the HTTP handler, coupling transport logic to prompt formatting.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Designing a Pluggable 4-Tier Context Engine
&lt;/h2&gt;

&lt;p&gt;To address this cleanly, we recently restructured the context architecture into four distinct operational tiers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────────────────────────────────────────────────────────────────┐
│                        CONTEXT TAXONOMY                                │
├────────────────────────────────────────────────────────────────────────┤
│ 1. Conversational Working Context (Multi-turn session &amp;amp; thread state)  │
│ 2. Long-Term &amp;amp; Semantic Memory (User preferences, key facts, recall)   │
│ 3. Sovereign Identity &amp;amp; Security Context (Roles, clearance, metadata)  │
│ 4. Procedural &amp;amp; Skill Knowledge (Domain runbooks, safe tool sequencing)│
└────────────────────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rather than baking assumptions about prompt format or storage backends directly into the core execution loop, we introduced a &lt;code&gt;ContextProvider&lt;/code&gt; abstraction into the commons layer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nd"&gt;#[async_trait]&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;trait&lt;/span&gt; &lt;span class="n"&gt;ContextProvider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Send&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;Sync&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cd"&gt;/// Enrich the prompt or messages before the LLM thinking phase&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;enrich_context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;ContextRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="nb"&gt;Vec&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Message&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Result&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="cd"&gt;/// Post-turn hook to record dialogue or extract persistent facts&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;on_turn_complete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;ContextRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;user_message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;assistant_message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Result&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How the Execution Pipeline Works
&lt;/h3&gt;

&lt;p&gt;When a request arrives, &lt;code&gt;McpAgent&lt;/code&gt; executes a two-phase context pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Request (with session_id &amp;amp; metadata)
          │
          ▼
┌────────────────────────────────────────────────────────┐
│              CONTEXT ASSEMBLER PIPELINE                │
│                                                        │
│  1. Base System Prompt                                 │
│  2. Identity Provider   ──&amp;gt; Injects identity block     │
│  3. Skill Provider      ──&amp;gt; Injects tool runbooks      │
│  4. Fact Memory Provider──&amp;gt; Recalls relevant facts     │
│  5. History Provider    ──&amp;gt; Loads sliding window turns │
│  6. Current User Turn                                  │
└──────────────────────────┬─────────────────────────────┘
                           │
                           ▼
           ┌───────────────────────────────┐
           │      McpAgent Run Context     │
           │      (Enriched Message List)  │
           └───────────────┬───────────────┘
                           │
                           ▼
           ┌───────────────────────────────┐
           │    McpAgent Execution Loop    │
           │ Thinking ──&amp;gt; Executing Tools  │
           └───────────────┬───────────────┘
                           │ (Assistant Response)
                           ▼
┌────────────────────────────────────────────────────────┐
│                   POST-TURN FLUSH                      │
│  • Persist User &amp;amp; Assistant turns to MemoryService     │
│  • Invoke `on_turn_complete` on all context providers  │
└────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sliding Window History (&lt;code&gt;HistoryContextProvider&lt;/code&gt;):&lt;/strong&gt;&lt;br&gt;
The provider queries &lt;code&gt;MemoryService::get_conversation(session_id, limit)&lt;/code&gt;, fetching the last $N$ turns (configurable via TOML) and injecting them between the system prompt and the latest user turn. Older turns can be safely compacted or truncated without blowing past LLM context limits.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Persistent Fact Recall (&lt;code&gt;SemanticMemoryContextProvider&lt;/code&gt;):&lt;/strong&gt;&lt;br&gt;
A dedicated &lt;code&gt;db_facts&lt;/code&gt; store exposes &lt;code&gt;store_fact&lt;/code&gt; and &lt;code&gt;recall_facts&lt;/code&gt;. Before LLM execution, facts matching the user's query or category are recalled and attached as structured context.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Identity &amp;amp; Security Context (&lt;code&gt;IdentityContextProvider&lt;/code&gt;):&lt;/strong&gt;&lt;br&gt;
Injects caller metadata, tenant identification, active permissions, and clearance level into an &lt;code&gt;&amp;lt;identity_context&amp;gt;&lt;/code&gt; block, ensuring the model stays aligned with authorization boundaries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Zero-Breaking-Change Guarantee:&lt;/strong&gt;&lt;br&gt;
To ensure existing deployments remain stable, all methods added to the &lt;code&gt;MemoryService&lt;/code&gt; trait provide default no-op implementations. If an agent does not configure memory services or context providers, it continues operating in the original stateless mode with zero performance regression.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Why Rust for Multi-Agent &amp;amp; Gateway Infrastructure?
&lt;/h2&gt;

&lt;p&gt;Rust is well-suited for this specific intersection of workloads for several reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Concurrency Without Global Locks:&lt;/strong&gt; Shared state across concurrent sessions (such as &lt;code&gt;DashMap&lt;/code&gt;-backed memory tables and cached tool schemas) operates cleanly across Tokio worker threads without coarse mutex contention.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Low Latency &amp;amp; Predictable Footprint:&lt;/strong&gt; When proxying high-token streaming requests or managing complex tool calls, predictable memory ownership avoids garbage-collection pause spikes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compile-Time Protocol Validation:&lt;/strong&gt; Using strongly typed structs for A2A and MCP message boundaries surfaces serialization and schema mismatches at compile time rather than midway through an automated workflow.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Configuration Example
&lt;/h2&gt;

&lt;p&gt;Enabling context memory in an agent runtime is handled declaratively in the configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[agent_mcp]&lt;/span&gt;
&lt;span class="py"&gt;agent_mcp_model_id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"openai/gpt-oss-20b"&lt;/span&gt;
&lt;span class="py"&gt;agent_mcp_llm_url&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"https://api.groq.com/openai/v1/chat/completions"&lt;/span&gt;
&lt;span class="py"&gt;agent_mcp_system_prompt&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"You are a specialized customer domain agent."&lt;/span&gt;

&lt;span class="c"&gt;# Context Engine Settings&lt;/span&gt;
&lt;span class="py"&gt;agent_mcp_history_length&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="py"&gt;agent_mcp_enable_memory_recall&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="py"&gt;agent_mcp_enable_identity_context&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Trade-offs and Open Questions
&lt;/h2&gt;

&lt;p&gt;In designing this system, we encountered several trade-offs that have no single "correct" answer:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sliding Window vs. Recursive Summarization:&lt;/strong&gt;
A fixed sliding window is fast, deterministic, and adds zero LLM cost. However, long-running threads inevitably drop older details. A recurring compactor that periodically condenses earlier turns into a narrative summary solves this, but incurs additional latency and inference cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key-Value Fact Storage vs. Vector Embeddings:&lt;/strong&gt;
For local and edge environments, key-value fact matching (by key, tag, and query substring) avoids the operational burden of running an embedding model or vector database. For large-scale unstructured corpora, however, vector embeddings remain necessary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Glued vs. Decoupled Deployments:&lt;/strong&gt;
Providing both "Full Swarm" and "Gateway-Only" patterns allows teams to start simple and observe traffic patterns empirically. Rather than guessing the ideal microservice boundary on day one, letting actual load, blast radius considerations, and operational ownership dictate whether the gateway and orchestrator remain glued has proved much less painful than premature decomposition.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We would be glad to hear from developers building agent systems or LLM gateways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;How do you manage conversation history compaction across extended agent workflows?&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Do you prefer combining proxy routing and agent execution into a single binary, or keeping them decoupled across services?&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Project &amp;amp; Code
&lt;/h2&gt;

&lt;p&gt;If you are interested in exploring the implementation, testing the multi-agent kickstarts, or examining the MCP runtime contracts, the project is open-source under Apache-2.0:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://github.com/fcn06/swarm" rel="noopener noreferrer"&gt;Swarm on GitHub&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Contributions, critiques, and discussions are welcome.&lt;/p&gt;

</description>
      <category>rust</category>
      <category>ai</category>
      <category>agents</category>
      <category>gateway</category>
    </item>
    <item>
      <title>The Agent Economy: Why Agents Must Negotiate Agreements, and How It Rewrites Integration.</title>
      <dc:creator>fcn06</dc:creator>
      <pubDate>Wed, 09 Sep 2026 17:25:02 +0000</pubDate>
      <link>https://dev.to/fcn06/the-agent-economy-needs-a-trust-layer-49c</link>
      <guid>https://dev.to/fcn06/the-agent-economy-needs-a-trust-layer-49c</guid>
      <description>&lt;p&gt;The pitch for autonomous AI agents has quietly shifted. &lt;/p&gt;

&lt;p&gt;A year ago, agentic AI meant giving an LLM access to your local bash terminal or a calculator. Today, the conversation is about the &lt;strong&gt;agent economy&lt;/strong&gt;: autonomous agents from different companies discovering one another, negotiating terms, ordering goods, and settling transactions at machine speed.&lt;/p&gt;

&lt;p&gt;That sounds great on a slide deck. But look at how people actually build cross-enterprise agent integrations today, and you'll find a massive disconnect.&lt;/p&gt;

&lt;p&gt;Most current implementations treat the "agent economy" as nothing more than handing an LLM an API key to a counterparty's REST endpoint, wrapping it in a system prompt, and crossing their fingers. If Company A's agent wants to buy something from Company B, either human engineers spend three months writing bespoke integration code, or Company B gives Company A's model raw access to an internal tool and prays prompt injection doesn't drain their inventory.&lt;/p&gt;

&lt;p&gt;Neither model works. &lt;/p&gt;

&lt;p&gt;Real economies don't run on hardcoded API calls, and they certainly don't run on blind faith in a counterparty's system prompt. Real economies run on &lt;strong&gt;negotiated agreements between sovereign parties who don't control each other&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If we want a genuine agent economy, agents must be able to negotiate agreements with other agents. And to do that safely, we need to understand what agents should negotiate — and what they must never be allowed to touch.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem: APIs Are Static, But Business Is Dynamic
&lt;/h2&gt;

&lt;p&gt;Today, enterprise B2B integration is painfully rigid:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Company A (Custom Code) ──[Months of Specs &amp;amp; Mapping]──&amp;gt; Company B (REST API)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Company B has to document endpoints, schemas, authentication scopes, webhooks, and rate limits. Company A has to hire engineers to read all of it and write bespoke glue code. Even when both use standard formats like JSON or OpenAPI, their business semantics almost never match. (Does "cancel order" mean voiding the PO immediately, or does it mean submitting a cancellation request subject to supplier review?)&lt;/p&gt;

&lt;p&gt;Agents change the equation because they can &lt;strong&gt;reason about intent&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Instead of calling &lt;code&gt;POST /api/v3/orders&lt;/code&gt; with twenty hardcoded parameters, Company A's agent can say:&lt;br&gt;&lt;br&gt;
&lt;em&gt;"I need 500 industrial bearings delivered to our Lyon warehouse before next Friday. Target budget is under €15,000."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It's tempting to think: &lt;em&gt;"Great! LLMs replace APIs. Agents will just chat with each other in natural language and do business."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That would be a catastrophe.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Two probabilistic models chatting freely across company boundaries can hallucinate prices, misinterpret delivery terms, or fall prey to prompt injection. A natural language chat is not a business contract.&lt;/p&gt;

&lt;p&gt;The breakthrough isn't replacing APIs with LLM conversations. The breakthrough is &lt;strong&gt;using agents to negotiate a machine-readable agreement at runtime&lt;/strong&gt;, while keeping the underlying APIs as the deterministic execution engine.&lt;/p&gt;




&lt;h2&gt;
  
  
  Enter the Interaction Contract
&lt;/h2&gt;

&lt;p&gt;Imagine Company A's procurement agent discovers Company B's sales agent. Instead of firing arbitrary requests, the two agents engage in a structured negotiation to establish an &lt;strong&gt;Interaction Contract&lt;/strong&gt; — a shared, machine-readable definition of their relationship for this task:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────────┐      Propose Capabilities &amp;amp; Terms       ┌────────────────┐
│   Company A    │ ───────────────────────────────────────&amp;gt; │   Company B    │
│   B2B Agent    │ &amp;lt;─────────────────────────────────────── │   B2B Agent    │
└────────────────┘         Counter-Offer &amp;amp; Agreement        └────────────────┘
                                    │
                                    ▼
                     ┌─────────────────────────────┐
                     │    Interaction Contract     │
                     │  (Signed, Hashed, Versioned)│
                     └─────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A negotiated contract might look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;purpose&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;supplier_parts_procurement&lt;/span&gt;
&lt;span class="na"&gt;counterparties&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;buyer&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;did:web:company-a.com:agent-procure&lt;/span&gt;
  &lt;span class="na"&gt;seller&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;did:web:company-b.com:agent-sales&lt;/span&gt;

&lt;span class="na"&gt;capabilities&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;quote&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;create_order&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;track_shipment&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;cancel_order&lt;/span&gt;

&lt;span class="na"&gt;constraints&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;max_order_value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;currency&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;EUR&lt;/span&gt;
    &lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15000&lt;/span&gt;
  &lt;span class="na"&gt;geography&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;delivery_destination&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;EU&lt;/span&gt;

&lt;span class="na"&gt;cancellation&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;allowed_until&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;dispatch&lt;/span&gt;
  &lt;span class="na"&gt;penalty&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;

&lt;span class="na"&gt;validity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;expires_at&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;2026-10-01T00:00:00Z"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice what just happened:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Zero custom glue code was written in advance.&lt;/strong&gt; The agents dynamically discovered each other's capabilities and negotiated mutually agreeable terms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The relationship is strictly bounded.&lt;/strong&gt; Company A's agent cannot suddenly execute a €50,000 order or deliver to an unsupported jurisdiction; the contract rules it out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It's a bilateral agreement, not a unilateral permission list.&lt;/strong&gt; Unlike a static API token or OAuth scope, an Interaction Contract binds both parties to shared constraints, settlement rules, and validity windows. Both sides cryptographically sign it.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  The Critical Rule: Agents Negotiate Meaning, Not Authority
&lt;/h2&gt;

&lt;p&gt;Here is the load-bearing architectural principle that makes this entire model work:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Agents negotiate meaning and operational terms. They do NOT decide execution authority.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;An LLM is fantastic at reconciling differences. It can negotiate whether payment is in EUR or USD, map Company A's &lt;code&gt;shipping_address&lt;/code&gt; to Company B's &lt;code&gt;destination_facility&lt;/code&gt;, or agree on a cancellation window. That is &lt;strong&gt;semantic negotiation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But an agent should never have the power to approve its own authority. If Company A's agent and Company B's agent agree on a €50,000 transaction limit, but Company A's internal corporate policy says automated agents are capped at €10,000, &lt;strong&gt;enterprise policy must always win&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;An agent's effective authority is always the strict intersection of three layers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────────────────────────────────────────────────┐
│                  EFFECTIVE AUTHORITY                   │
│                           =                            │
│   Negotiated Contract  ∩  Enterprise Policy  ∩  Identity │
└────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Negotiated Contract (Bilateral):&lt;/strong&gt; What did both agents agree to? (e.g., max €15,000).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enterprise Policy (Local &amp;amp; Deterministic):&lt;/strong&gt; What does your company allow right now? (e.g., max €10,000, EU hours only).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent Identity (Cryptographic):&lt;/strong&gt; Is the calling agent who it claims to be, backed by a verified &lt;code&gt;did:web&lt;/code&gt; and active keys?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Negotiation can only &lt;strong&gt;shrink&lt;/strong&gt; the permitted operational space. It can never expand beyond what deterministic enterprise policy permits.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where the Trust Gateway Fits In
&lt;/h2&gt;

&lt;p&gt;Once the two agents negotiate and sign an Interaction Contract, how do we prevent either agent from deviating from it during execution?&lt;/p&gt;

&lt;p&gt;This is where a deterministic control plane — what we call a Trust Gateway — sits behind each organization's agent. &lt;/p&gt;

&lt;p&gt;Each party runs their own gateway at their enterprise boundary. It treats both external counterparties and internal LLMs as untrusted actors.&lt;/p&gt;

&lt;p&gt;The architecture cleanly separates responsibilities into three distinct roles:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────────────────────────┐         A2A / Negotiation         ┌────────────────────────────────┐
│           COMPANY A            │ ◄───────────────────────────────► │           COMPANY B            │
│  [ B2B Buyer Agent ]           │                                   │  [ B2B Seller Agent ]          │
│          │ (Proposes Action)   │    ┌─────────────────────────┐    │          │ (Proposes Action)   │
│          ▼                     │    │  Interaction Contract   │    │          ▼                     │
│  [ Trust Gateway A ] ──────────┼──► │ (Signed, Hashed, Shared)│ ◄──┼──────────[ Trust Gateway B ]   │
│          │ (Execution Grant)   │    └─────────────────────────┘    │          │ (Execution Grant)   │
│          ▼                     │                                   │          ▼                     │
│  [ Local Tool Executor ]       │                                   │  [ Local Tool Executor ]       │
│  (Internal ERP / Payment)      │                                   │  (Internal ERP / Inventory)    │
└────────────────────────────────┘                                   └────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Agents Propose:&lt;/strong&gt; The agent figures out what needs to be done under the negotiated contract and submits a &lt;code&gt;ProposedAction&lt;/code&gt; (e.g., "Create order for 500 bearings at €12,500").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Gateway Authorizes:&lt;/strong&gt; A deterministic engine written in pure Rust (no LLM, no fuzziness) verifies:

&lt;ul&gt;
&lt;li&gt;Does this action match the signed Interaction Contract?&lt;/li&gt;
&lt;li&gt;Does it comply with local enterprise risk rules?&lt;/li&gt;
&lt;li&gt;Is the counterparty's identity authentic?&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Executor Verifies:&lt;/strong&gt; If approved, the gateway mints a single-use, cryptographically signed &lt;strong&gt;Execution Grant&lt;/strong&gt; (Ed25519) with the canonical hash of the arguments. The executor verifies the grant signature before touching real-world databases, payment rails, or ERP APIs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If someone prompt-injects the agent mid-session or the model hallucinates an order for €50,000, the proposal hits the gateway, fails the contract verification, and gets rejected on the spot. Zero state change. Zero financial loss.&lt;/p&gt;




&lt;h2&gt;
  
  
  Sorting Out the Alphabet Soup: MCP vs. A2A vs. Contracts vs. Gateways
&lt;/h2&gt;

&lt;p&gt;With so many agent standards emerging, it's easy to get confused. Here is how they cleanly stack together:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Protocol / Concept&lt;/th&gt;
&lt;th&gt;Primary Role&lt;/th&gt;
&lt;th&gt;Analogy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Tool Interface&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;MCP&lt;/strong&gt; (Model Context Protocol)&lt;/td&gt;
&lt;td&gt;How an agent talks to its internal tools and data sources.&lt;/td&gt;
&lt;td&gt;The USB port connecting the computer to peripherals.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Communication&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;A2A&lt;/strong&gt; (Agent-to-Agent)&lt;/td&gt;
&lt;td&gt;How two agents discover each other and exchange messages.&lt;/td&gt;
&lt;td&gt;The telephone line between two offices.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Relationship&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Interaction Contract&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The negotiated operational agreement defining &lt;em&gt;what&lt;/em&gt; the two parties agreed to do.&lt;/td&gt;
&lt;td&gt;The signed business agreement between two companies.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Enforcement&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Trust Gateway&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The deterministic bouncer ensuring actions strictly match the contract and policy.&lt;/td&gt;
&lt;td&gt;The legal and compliance department with the key to the vault.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You don't have to choose between MCP, A2A, and secure contracts. They solve completely different layers of the problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A2A&lt;/strong&gt; gives agents the wire protocol to talk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MCP&lt;/strong&gt; gives them tools to execute.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interaction Contracts&lt;/strong&gt; define what they are allowed to agree on.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trust Gateways&lt;/strong&gt; guarantee neither side can break the rules.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why This Unlocks the Real Agent Economy
&lt;/h2&gt;

&lt;p&gt;The current debate around AI agents is stuck in a false dichotomy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Camp A (Full Autonomy):&lt;/strong&gt; "Give the LLM an API key and let it roam the web!" (Terrifying for any CISO or CFO).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Camp B (Zero Autonomy):&lt;/strong&gt; "Keep humans in the loop for every single button click." (Destroys the efficiency of automated software).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Negotiated agreements backed by deterministic gateways offer the way forward:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Autonomous at runtime:&lt;/strong&gt; Agents dynamically discover counterparties, map schemas, and negotiate constraints without human engineers writing point-to-point integration code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Governed by design:&lt;/strong&gt; Every action is cryptographically tied to a negotiated contract and evaluated against enterprise policy before execution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;APIs don't disappear — the boundary moves up:&lt;/strong&gt; Your ERP, banking APIs, and inventory systems remain deterministic, reliable, and auditable. What changes is that you no longer need to spend months standardizing every endpoint before two organizations can do business.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The real agent economy won't be built on chatbots clicking buttons. It will be built on sovereign agents negotiating structured agreements, enforced by mathematical and cryptographic guarantees.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;We've open-sourced our experiments and reference implementation for the Trust Gateway and Interaction Contracts on GitHub: &lt;a href="https://github.com/fcn06/trust_gateway" rel="noopener noreferrer"&gt;fcn06/trust_gateway&lt;/a&gt;. If you want to dive deeper into the full architecture, threat model, and formal protocols, check out the technical whitepaper: &lt;a href="https://github.com/fcn06/trust_gateway/blob/main/whitepaper/b2b_agent_whitepaper.md" rel="noopener noreferrer"&gt;Interaction Contracts for Autonomous B2B Agents&lt;/a&gt;.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;We'd love to hear your thoughts: in your domain, what parts of a B2B relationship could safely be negotiated by agents at runtime, and what must remain permanently hardcoded?&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>rust</category>
      <category>agents</category>
      <category>a2a</category>
    </item>
    <item>
      <title>Stop Giving AI Agents Your Master Password: UCAN Delegation</title>
      <dc:creator>fcn06</dc:creator>
      <pubDate>Sun, 23 Aug 2026 08:02:16 +0000</pubDate>
      <link>https://dev.to/fcn06/stop-giving-ai-agents-your-master-password-a-plain-english-guide-to-ucan-delegation-5ef3</link>
      <guid>https://dev.to/fcn06/stop-giving-ai-agents-your-master-password-a-plain-english-guide-to-ucan-delegation-5ef3</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Why handing a permanent API key to an autonomous AI agent is a bad idea — and a simpler way to grant it just enough trust, for just long enough, using cryptographic "visas" called UCANs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Status: work in progress.&lt;/strong&gt; This is an early write-up of something I'm actively building, not a finished product announcement. I'm sharing it specifically to get feedback — on the idea, the explanation, and the approach itself — before taking it further. See the last section for exactly what kind of feedback would help most.&lt;/p&gt;




&lt;h2&gt;
  
  
  The problem, in one picture
&lt;/h2&gt;

&lt;p&gt;Imagine you hire an intern to add one meeting to your Google Calendar. Would you hand them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A)&lt;/strong&gt; Your Google password — which also opens your email, your Drive, and your saved credit cards, or&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;B)&lt;/strong&gt; A note that says &lt;em&gt;"You may add one event, today, between 2 and 4 PM. Nothing else."&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everyone picks B for a human intern. Almost nobody picks B for an AI agent.&lt;/p&gt;

&lt;p&gt;Today, most AI agent frameworks (LangChain, CrewAI, AutoGen, and friends) are wired up with &lt;strong&gt;Option A&lt;/strong&gt;: a permanent, all-powerful API key pasted straight into the agent's code or environment variables. If that agent gets tricked by a malicious webpage, hallucinates, or simply has a bug, it doesn't just fail — it fails &lt;em&gt;with full permissions&lt;/em&gt;. Wiped databases and drained accounts are not hypothetical; they're a Tuesday.&lt;/p&gt;

&lt;p&gt;The obvious fix — "just ask the human before every single click" — kills the entire point of having an autonomous agent. Nobody wants to approve every calendar invite by hand.&lt;/p&gt;

&lt;p&gt;We wanted a third option: agents that can act on their own, but only within a narrow, time-boxed, cryptographically provable slice of permission. That's what this article walks through.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuidu45tk65zs83xqgoeq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuidu45tk65zs83xqgoeq.png" alt=" " width="800" height="666"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The idea: give agents a passport, not a master key
&lt;/h2&gt;

&lt;p&gt;Think about how &lt;em&gt;you&lt;/em&gt; cross a border. You don't hand a customs officer your entire identity and bank access — you hand them a &lt;strong&gt;passport&lt;/strong&gt;, and inside it, a &lt;strong&gt;visa&lt;/strong&gt; that says exactly which country you can enter, for how long, and for what purpose.&lt;/p&gt;

&lt;p&gt;We apply the same idea to AI agents:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;UCAN&lt;/strong&gt; (User Controlled Authorization Network) is the digital equivalent of a visa: a small, signed piece of proof that says &lt;em&gt;"person X allows agent Y to do Z, until this time."&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Virtual Passport&lt;/strong&gt; is the little folder an agent carries around, holding all the UCANs (visas) it has been issued by different people or departments.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; ┌──────────────────────────────────────────────────────────┐
 │                AGENT'S VIRTUAL PASSPORT                  │
 │  Agent: "Supervisor Agent #7721"                          │
 │                                                            │
 │  🎫 Visa #1 — issued by Alice                              │
 │     Allowed: create a Google Calendar event                │
 │     Valid for: 10 minutes                                  │
 │                                                            │
 │  🎫 Visa #2 — issued by Finance                            │
 │     Allowed: approve refunds up to $50                     │
 │     Valid for: 1 hour                                      │
 └──────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each visa is signed with real cryptography (Ed25519 signatures), so nobody can forge one or quietly extend its lifetime. Under the hood, a UCAN is just a small, signed JSON object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"issuer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"did:twin:alice..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"audience"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"did:twin:supervisor-agent..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"capabilities"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"google_calendar"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"create_event"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"expiry"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1787491200&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;issuer&lt;/strong&gt; — who is granting the permission (Alice)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;audience&lt;/strong&gt; — who receives it (the agent)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;capabilities&lt;/strong&gt; — exactly what the agent may do, nothing more&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;expiry&lt;/strong&gt; — the moment this visa stops working, automatically&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No central authority has to revoke anything — the token simply stops being valid. That's the whole trick.&lt;/p&gt;




&lt;h2&gt;
  
  
  A narrower visa for a narrower job: delegation
&lt;/h2&gt;

&lt;p&gt;Here's the part that makes this genuinely useful for multi-agent systems, not just a single bot: &lt;strong&gt;an agent can hand a smaller visa to another agent.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Say Alice asks her "Supervisor" agent to schedule a client meeting. The Supervisor spins up a small "Worker" agent just to touch the calendar. It doesn't hand the Worker its &lt;em&gt;own&lt;/em&gt; visa (which might also include refund permissions) — it mints a &lt;strong&gt;new, narrower visa&lt;/strong&gt;, stripped down to exactly &lt;code&gt;calendar: create_event&lt;/code&gt;, and nothing else.&lt;/p&gt;

&lt;p&gt;This is called &lt;strong&gt;attenuation&lt;/strong&gt;: every time permission is delegated, it can only get &lt;em&gt;narrower&lt;/em&gt;, never wider. A worker agent can never end up with more power than its supervisor had. That single rule is what makes it safe to build swarms of agents that spawn other agents without the whole thing turning into a permissions free-for-all.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqxn3wp0ywun6tl730rps.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqxn3wp0ywun6tl730rps.png" alt=" " width="800" height="306"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What actually happens when the agent tries to act
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7h3esgs9sv0hv4oumwym.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7h3esgs9sv0hv4oumwym.png" alt=" " width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two things are worth noticing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The agent never talks to Google Calendar directly with a permanent credential.&lt;/strong&gt; It shows its visa to a middleman — the &lt;strong&gt;Trust Gateway&lt;/strong&gt; — which checks that everything is legitimate and in-scope, then issues a tiny, single-use pass valid for just 30 seconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;That 30-second pass is also cryptographically tied to the exact action requested&lt;/strong&gt; (the specific meeting title and time, hashed). Even if it leaked, it couldn't be replayed or repurposed for a different action.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If an agent ever tries to do something &lt;em&gt;outside&lt;/em&gt; what its visa allows — say, a $500 refund when it only has a $50 visa — the request doesn't fail silently or get approved anyway. It gets parked and sent to the human for a real approval (a fingerprint or Face ID tap on their phone), before anything happens.&lt;/p&gt;

&lt;p&gt;So the agent gets to act autonomously &lt;em&gt;within its lane&lt;/em&gt;, and a human only gets pulled in when something falls outside that lane. That's the balance the "God-mode key vs. approve-everything" dilemma from the start of this article was missing.&lt;/p&gt;




&lt;h2&gt;
  
  
  Trying it yourself
&lt;/h2&gt;

&lt;p&gt;The gateway that does the checking — the &lt;strong&gt;Trust Gateway&lt;/strong&gt; — is open source and written in Rust. Here's the shortest possible version of the flow above, using its API directly. All three calls below are handled entirely inside the open-source &lt;code&gt;trust_gateway&lt;/code&gt; itself — no other service is involved in minting, validating, or checking policy on a token.&lt;/p&gt;

&lt;p&gt;Swap in your own gateway's address wherever you see &lt;code&gt;&amp;lt;YOUR-TRUST-GATEWAY-URL&amp;gt;&lt;/code&gt; (e.g. &lt;code&gt;http://127.0.0.1:3060&lt;/code&gt; if you're running it locally).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Alice mints a visa for her agent&lt;/strong&gt;, scoped to calendar access only, for one hour:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="nt"&gt;-X&lt;/span&gt; POST https://&amp;lt;YOUR-TRUST-GATEWAY-URL&amp;gt;/v1/ucan/mint &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{
    "issuer": "did:twin:alice...",
    "audience": "did:twin:supervisor-agent...",
    "capabilities": [{ "resource": "google_calendar", "action": "create_event" }],
    "ttl_seconds": 3600,
    "issuer_seed_hex": "&amp;lt;alice_private_seed&amp;gt;"
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This returns a signed UCAN token — the digital visa.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Anyone can verify that visa, without contacting Alice&lt;/strong&gt;, because the proof is self-contained:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="nt"&gt;-X&lt;/span&gt; POST https://&amp;lt;YOUR-TRUST-GATEWAY-URL&amp;gt;/v1/ucan/validate &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{
    "ucan_token": "&amp;lt;the token from step 1&amp;gt;",
    "required_resource": "google_calendar",
    "required_action": "create_event"
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. The agent proposes the actual action.&lt;/strong&gt; The Gateway checks the visa and, if everything lines up, mints the short-lived execution pass:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="nt"&gt;-X&lt;/span&gt; POST https://&amp;lt;YOUR-TRUST-GATEWAY-URL&amp;gt;/v1/actions/propose &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{
    "action_name": "google_calendar_create_event",
    "arguments": {
      "summary": "Architecture Review",
      "start_time": "2026-09-01T14:00:00Z"
    },
    "ucan_token": "&amp;lt;the token from step 1&amp;gt;"
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it — three calls, entirely served by the open-source gateway, and you've reproduced the whole "mint a scoped permission, verify it, use it once" cycle. The full API also lets an agent prove it holds &lt;em&gt;one&lt;/em&gt; specific capability without revealing the rest of its passport (handy if it's carrying visas it shouldn't disclose), and lets you inspect an agent's live passport at any time. Both are just extensions of the same idea. Turning that final execution pass into a real side effect (actually touching Google Calendar) is the one piece that needs something outside the gateway — a downstream tool consumer to carry it out — but the entire token lifecycle and governance you just exercised runs on &lt;code&gt;trust_gateway&lt;/code&gt; alone.&lt;/p&gt;




&lt;h2&gt;
  
  
  Open source
&lt;/h2&gt;

&lt;p&gt;Everything described in this article — UCAN minting and validation, delegation, and execution-grant issuance — lives in the open-source Trust Gateway, written in Rust and runnable locally today:&lt;br&gt;
👉 &lt;strong&gt;&lt;a href="https://github.com/fcn06/trust_gateway" rel="noopener noreferrer"&gt;github.com/fcn06/trust_gateway&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Don't hand AI agents permanent, all-powerful API keys.&lt;/strong&gt; It's the equivalent of giving an intern your master password.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Give them a passport of short-lived, narrowly scoped visas instead&lt;/strong&gt; — cryptographically signed, automatically expiring, and impossible to widen through delegation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check every action at the door&lt;/strong&gt;, with a lightweight gateway that turns a valid visa into a single-use, single-action execution pass.
The agent still acts on its own. It just can't act beyond what it was actually trusted to do — and that trust is provable, not just assumed.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  I'd like your feedback
&lt;/h2&gt;

&lt;p&gt;This is still a work in progress, and I'd genuinely like to hear from people who read this — whether you build agents, work in security, or just have an opinion. A few specific things I'm unsure about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The core idea:&lt;/strong&gt; Does scoping AI agent permissions with short-lived, delegatable visas (UCANs) actually solve a problem you've run into, or does it feel like overkill for how you use agents today?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The explanation:&lt;/strong&gt; Was the passport/visa analogy clear, or did it break down somewhere once the delegation and execution-grant parts came in?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The gaps:&lt;/strong&gt; What's missing that would make you trust this in production — key rotation, revocation before expiry, auditability, something else?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The demo:&lt;/strong&gt; If you tried the three &lt;code&gt;curl&lt;/code&gt; calls yourself, did they work as described? Anything confusing about the request/response shapes?
Comments here are the easiest way to reach me, but I'll also take issues or pull requests on the &lt;a href="https://github.com/fcn06/trust_gateway" rel="noopener noreferrer"&gt;GitHub repo&lt;/a&gt;. If you spend five minutes poking holes in this, I'll read every one of them.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>humanintheloop</category>
      <category>virtualpassport</category>
      <category>agents</category>
    </item>
    <item>
      <title>You Don't Need to Choose Between a Gateway and an Agent Framework</title>
      <dc:creator>fcn06</dc:creator>
      <pubDate>Fri, 21 Aug 2026 15:32:51 +0000</pubDate>
      <link>https://dev.to/fcn06/you-dont-need-to-choose-between-a-gateway-and-an-agent-framework-2gma</link>
      <guid>https://dev.to/fcn06/you-dont-need-to-choose-between-a-gateway-and-an-agent-framework-2gma</guid>
      <description>&lt;p&gt;When I first published &lt;a href="https://github.com/fcn06/swarm" rel="noopener noreferrer"&gt;Swarm&lt;/a&gt; on GitHub, most questions weren't about Rust or MCP. They were about timing and categorization:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"We just need a lightweight gateway for multi-provider routing; agents feel like overkill."&lt;/p&gt;

&lt;p&gt;"We already run an orchestration framework; why would we replace our proxy?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This reaction highlights a false dichotomy currently plaguing the AI infrastructure ecosystem: the assumption that a gateway and an agent orchestrator must be two completely different products.&lt;/p&gt;

&lt;p&gt;In practice, teams rarely wake up needing full-blown multi-agent autonomous swarms on Day 1. But when they start with a standalone proxy, they inevitably hit a wall — patching together Python microservices, external vector state stores, MCP bridges, and ad-hoc eval scripts. Every evolution requires a rewrite.&lt;/p&gt;

&lt;p&gt;The core premise of Swarm is different: a single, pure-Rust runtime where you don't choose between a gateway and an orchestrator — you simply choose which capabilities to turn on.&lt;/p&gt;




&lt;h2&gt;
  
  
  The AI Adoption Ladder
&lt;/h2&gt;

&lt;p&gt;Most engineering teams evolve their LLM stack along a predictable trajectory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rung 1: OpenAI-Compatible Gateway   (Drop-in replacement for hardcoded SDKs)
  └── Rung 2: Multi-Provider Fallbacks (Groq, Gemini, Ollama, vLLM via TOML)
        └── Rung 3: Stateful Sessions     (Previous response chaining &amp;amp; context)
              └── Rung 4: Native MCP Tools    (SSE + Streamable HTTP tool execution)
                    └── Rung 5: Multi-Agent DAGs  (Planner + Executor + Specialists)
                          └── Rung 6: Built-in Evals    (LLM-as-a-Judge &amp;amp; policy gates)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can stop at any rung and have a lean, production-grade binary. When you're ready for the next level, you change a configuration flag — not your architectural foundation.&lt;/p&gt;




&lt;h2&gt;
  
  
  Rung 1 — Just a Low-Latency Gateway
&lt;/h2&gt;

&lt;p&gt;If your immediate goal is simply eliminating hardcoded API keys and single-vendor SDK locks, Swarm acts as an OpenAI-compatible drop-in front door with sub-millisecond native routing overhead.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Spin up the gateway in seconds&lt;/span&gt;
./kickstart/gateway_kickstart/01_launch_gateway.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST http://localhost:8080/v1/chat/completions &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{
    "model": "openai/gpt-4o-mini",
    "messages": [{"role": "user", "content": "Explain progressive disclosure in software."}]
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get instant OpenAI compatibility. No agent overhead, no background worker queues, no forced abstractions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Rung 2 — Multi-Provider &amp;amp; Local Model Routing
&lt;/h2&gt;

&lt;p&gt;When rate limits hit or you need cost-effective fallbacks across cloud and local runtimes (Groq, Anthropic, Gemini, Ollama, vLLM, llama.cpp), routing is declared cleanly in &lt;code&gt;config.toml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[providers.groq]&lt;/span&gt;
&lt;span class="py"&gt;api_url&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"https://api.groq.com/openai/v1/chat/completions"&lt;/span&gt;
&lt;span class="py"&gt;weight&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;

&lt;span class="nn"&gt;[providers.local_vllm]&lt;/span&gt;
&lt;span class="py"&gt;api_url&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"http://localhost:8000/v1/chat/completions"&lt;/span&gt;
&lt;span class="py"&gt;recommended_models&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"meta-llama/Llama-3.3-70B-Instruct"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your applications continue calling the same &lt;code&gt;/v1/chat/completions&lt;/code&gt; endpoint. Failover, load distribution, and local-inference routing happen invisibly inside the runtime.&lt;/p&gt;




&lt;h2&gt;
  
  
  Rung 3 — Stateful Conversations via &lt;code&gt;/v1/responses&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Multi-turn chat state is where teams often bolt on an external Redis or PostgreSQL session manager. Swarm provides explicit turn-by-turn state management natively through &lt;code&gt;/v1/responses&lt;/code&gt; using &lt;code&gt;previous_response_id&lt;/code&gt; chaining:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST http://localhost:8080/v1/responses &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{
    "model": "groq/llama-3.3-70b-versatile",
    "input": "Calculate the Q3 cloud infrastructure spend.",
    "previous_response_id": "resp_01JMW892KPA7XYZ"
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;State is managed by the runtime, eliminating client-side conversation bloat while keeping state inspection simple and deterministic.&lt;/p&gt;




&lt;h2&gt;
  
  
  Rung 4 — Native Model Context Protocol (MCP)
&lt;/h2&gt;

&lt;p&gt;When your model needs real-world context — database schemas, filesystem access, API calls — you shouldn't have to migrate to a heavy agent framework just to call tools.&lt;/p&gt;

&lt;p&gt;Swarm natively supports MCP (over both SSE and streamable HTTP) directly inside the gateway layer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[mcp_servers.postgres_db]&lt;/span&gt;
&lt;span class="py"&gt;transport&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"sse"&lt;/span&gt;
&lt;span class="py"&gt;url&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"http://localhost:3001/sse"&lt;/span&gt;

&lt;span class="nn"&gt;[mcp_servers.git_tools]&lt;/span&gt;
&lt;span class="py"&gt;transport&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"http"&lt;/span&gt;
&lt;span class="py"&gt;url&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"http://localhost:3002/mcp"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tool discovery, argument validation, and streaming tool execution run within the same engine that routes your completions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Rung 5 — Coordinated Multi-Agent Workflows
&lt;/h2&gt;

&lt;p&gt;When single-prompt loops cannot solve compound tasks, Swarm activates its autonomous orchestration engine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Intent
   │
   ▼
[ Planner ] ──► Builds Execution DAG (Dependencies &amp;amp; Concurrency)
   │
   ▼
[ Executor ] ──► Dispatches tasks across Domain Specialists
   │
   ├── Specialist A (Data Analyst + Postgres MCP)
   └── Specialist B (Report Writer + File MCP)
   │
   ▼
Unified Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why this matters:&lt;/strong&gt; Rung 5 reuses the identical provider configurations, fallback pools, state engine, and MCP tool connectors established in Rungs 1–4. There is no secondary agent daemon or translation bridge.&lt;/p&gt;




&lt;h2&gt;
  
  
  Rung 6 — Built-in LLM-as-a-Judge Evaluation
&lt;/h2&gt;

&lt;p&gt;The final rung is the one most gateways and agent frameworks omit entirely: closing the loop on quality.&lt;/p&gt;

&lt;p&gt;Instead of exporting logs to an external SaaS pipeline, Swarm embeds an LLM-as-a-Judge loop. It scores intermediate DAG outputs, validates MCP tool results against deterministic schemas, and flags hallucinated responses before they reach client applications:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST http://localhost:8080/v1/eval/judge &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{
    "response_id": "resp_01JMW892KPA7XYZ",
    "criteria": ["correctness", "grounding", "conciseness"],
    "judge_model": "openai/gpt-4o"
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This foundational layer enables our upcoming roadmap items: policy-based dynamic routing, durable state checkpoints, and human-in-the-loop validation gates.&lt;/p&gt;




&lt;h2&gt;
  
  
  Architectural Coherence Beats Glue Code
&lt;/h2&gt;

&lt;p&gt;The individual capabilities of Swarm — gateway proxying, MCP tool invocation, DAG planning, automated evaluation — exist across different open-source projects.&lt;/p&gt;

&lt;p&gt;What is rare is finding them integrated into a single, zero-dependency, memory-safe binary where adopting multi-agent orchestration doesn't invalidate the proxy architecture you set up on Day 1.&lt;/p&gt;

&lt;p&gt;The architectural bet of Swarm is simple: &lt;strong&gt;the tools you choose when you only need a gateway should never become technical debt the day you need agents.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Discussion
&lt;/h2&gt;

&lt;p&gt;If you're currently scaling your LLM infrastructure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;At which rung on this ladder has your team spent the most engineering time?&lt;/li&gt;
&lt;li&gt;Have you had to replace a gateway when moving to agents (or vice-versa)?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check out the project and try the kickstart scripts on GitHub: &lt;strong&gt;&lt;a href="https://github.com/fcn06/swarm" rel="noopener noreferrer"&gt;github.com/fcn06/swarm&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>llm</category>
      <category>mcp</category>
      <category>ai</category>
      <category>multiagent</category>
    </item>
  </channel>
</rss>
