<?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: Abhishek Tripathi</title>
    <description>The latest articles on DEV Community by Abhishek Tripathi (@atripati).</description>
    <link>https://dev.to/atripati</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3875063%2F564f9699-f430-4694-acd3-841f062a1f30.png</url>
      <title>DEV Community: Abhishek Tripathi</title>
      <link>https://dev.to/atripati</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/atripati"/>
    <language>en</language>
    <item>
      <title>I built an AI agent runtime that routes each step to a different model</title>
      <dc:creator>Abhishek Tripathi</dc:creator>
      <pubDate>Sun, 12 Apr 2026 18:49:05 +0000</pubDate>
      <link>https://dev.to/atripati/i-built-an-ai-agent-runtime-that-routes-each-step-to-a-different-model-3eao</link>
      <guid>https://dev.to/atripati/i-built-an-ai-agent-runtime-that-routes-each-step-to-a-different-model-3eao</guid>
      <description>&lt;h1&gt;
  
  
  Description:
&lt;/h1&gt;

&lt;p&gt;ARK is an open-source Go runtime that sends tool calls to cheap models and reasoning to expensive ones — automatically. Per-step cost tracking, persistent learning, 106 tests.&lt;/p&gt;

&lt;p&gt;Every AI agent framework I've used does the same thing: pick one model, use it for everything. GPT-4o for a simple tool call that extracts a parameter. GPT-4o for the final reasoning step. Same price per token regardless of complexity.&lt;br&gt;
That's like hiring a senior engineer to write config files.&lt;br&gt;
I built ARK to fix this. It's an open-source runtime in Go that routes each step in the agent loop to the optimal model.&lt;/p&gt;

&lt;h1&gt;
  
  
  What it looks like
&lt;/h1&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.amazonaws.com%2Fuploads%2Farticles%2Femg08cqbfr5r6jwxxg8j.jpeg" 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.amazonaws.com%2Fuploads%2Farticles%2Femg08cqbfr5r6jwxxg8j.jpeg" alt=" " width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  How routing works
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step Type&lt;/th&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Tool call (extract params)&lt;/td&gt;
&lt;td&gt;Fast&lt;/td&gt;
&lt;td&gt;Simple extraction, cheap           model is fine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Final reasoning/summary&lt;/td&gt;
&lt;td&gt;Strong&lt;/td&gt;
&lt;td&gt;Needs quality, worth paying for&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Error recovery/retry&lt;/td&gt;
&lt;td&gt;Strong&lt;/td&gt;
&lt;td&gt;Needs to understand what went wrong&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Grounding check&lt;/td&gt;
&lt;td&gt;Fast&lt;/td&gt;
&lt;td&gt;Simple validation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Configure it in one YAML block:&lt;/p&gt;

&lt;p&gt;model:&lt;br&gt;
  provider: openai&lt;br&gt;
  strategy: cost_optimized&lt;br&gt;
  fast_model: gpt-4o-mini&lt;br&gt;
  strong_model: gpt-4o&lt;/p&gt;

&lt;p&gt;Three strategies: single (one model, backwards compatible), cost_optimized (prefer cheap, fallback to strong), quality_first (always strong).&lt;/p&gt;

&lt;p&gt;The router learns&lt;/p&gt;

&lt;p&gt;If the fast model fails on a step type, ARK promotes it to the strong model next time. This persists across restarts in ark-router-learning.json.&lt;/p&gt;

&lt;p&gt;Run 1: tool_call on gpt-4o-mini → fails&lt;br&gt;
Run 1: fallback to gpt-4o → succeeds&lt;br&gt;
Run 2: tool_call goes directly to gpt-4o (learned from failure)&lt;/p&gt;

&lt;p&gt;No configuration needed. The router figures it out.&lt;/p&gt;

&lt;p&gt;But routing is only part of it&lt;/p&gt;

&lt;p&gt;ARK solves three problems together&lt;/p&gt;

&lt;h1&gt;
  
  
  1. Context waste
&lt;/h1&gt;

&lt;p&gt;MCP tools dump 60,000+ tokens of tool schemas into every prompt. ARK loads only 3-5 relevant tools per task.&lt;/p&gt;

&lt;p&gt;Raw MCP:  60,468 tokens  (30.2% of context)&lt;br&gt;
ARK:     ~80 tokens      (0.05% of context)&lt;br&gt;
Savings:  99.9%&lt;/p&gt;

&lt;h1&gt;
  
  
  2. Cost per decision
&lt;/h1&gt;

&lt;p&gt;Every step has a dollar amount. Cost feeds back into tool ranking — expensive tools that fail get demoted automatically.&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.amazonaws.com%2Fuploads%2Farticles%2F67hxs2j0mmz65idegpvj.jpeg" 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.amazonaws.com%2Fuploads%2Farticles%2F67hxs2j0mmz65idegpvj.jpeg" alt=" " width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  3. Learning across runs
&lt;/h1&gt;

&lt;p&gt;Tools that succeed get promoted. Tools that fail get demoted. Query patterns are remembered. Run 2 is smarter than Run 1.&lt;/p&gt;

&lt;p&gt;github-list:   0.378 → 0.954  (+152.7%)  after 3 runs&lt;br&gt;
github-search: 0.552 → 0.419  (-24.1%)   after 1 failure&lt;/p&gt;

&lt;h1&gt;
  
  
  The anti-hallucination gate
&lt;/h1&gt;

&lt;p&gt;If tools are available but the LLM tries to answer without calling them, ARK blocks it:&lt;/p&gt;

&lt;p&gt;Step 1: GROUNDING GATE — rejecting ungrounded answer, forcing tool use&lt;br&gt;
Step 2: TOOL_CALL — github_list_repos&lt;br&gt;
Step 3: COMPLETE — answer based on real data&lt;/p&gt;

&lt;p&gt;Zero hallucinated answers across 30 stress test runs.&lt;/p&gt;

&lt;h1&gt;
  
  
  Connect any API
&lt;/h1&gt;

&lt;p&gt;Define custom tools in agent.yaml. ARK handles domain allowlisting, parameter validation, cost tracking, and learning — automatically.&lt;br&gt;
tools:&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.amazonaws.com%2Fuploads%2Farticles%2Fd9sc1qbpi1lz1sc40ypg.jpeg" 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.amazonaws.com%2Fuploads%2Farticles%2Fd9sc1qbpi1lz1sc40ypg.jpeg" alt=" " width="800" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Headers support ${ENV_VAR} interpolation. Write operations are blocked by default. No code needed.&lt;/p&gt;

&lt;h1&gt;
  
  
  The numbers
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;106 tests, race detector clean&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;11 built-in tools (GitHub, Brave Search, file system)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;3 LLM providers (Anthropic, OpenAI, Ollama)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Single Go binary, zero external dependencies&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;30-run stress test: zero crashes, zero hallucination&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verified cost tracking against OpenAI's billing dashboard&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Try it
&lt;/h1&gt;

&lt;p&gt;git clone &lt;a href="https://github.com/atripati/ark.git" rel="noopener noreferrer"&gt;https://github.com/atripati/ark.git&lt;/a&gt;&lt;br&gt;
cd ark&lt;/p&gt;

&lt;h1&gt;
  
  
  No API keys needed for demos
&lt;/h1&gt;

&lt;p&gt;go run ./cmd/ark demo&lt;br&gt;
go run ./cmd/ark demo-learn &lt;br&gt;
go run ./cmd/ark bench&lt;/p&gt;

&lt;h1&gt;
  
  
  Real task with Ollama (free)
&lt;/h1&gt;

&lt;p&gt;go run ./cmd/ark run agent.yaml --task "list repos for openai"&lt;/p&gt;

&lt;h1&gt;
  
  
  With model routing (needs OpenAI key)
&lt;/h1&gt;

&lt;h1&gt;
  
  
  set strategy: cost_optimized in agent.yaml
&lt;/h1&gt;

&lt;p&gt;go run ./cmd/ark run agent.yaml --task "find most starred repo for openai, then list its issues"&lt;/p&gt;

&lt;h1&gt;
  
  
  What's next
&lt;/h1&gt;

&lt;p&gt;ARK is open source and actively developed. The next milestone is MCP server connector — so ARK can sit in front of any MCP server and manage its context automatically.&lt;/p&gt;

&lt;p&gt;If you're building AI agents and hitting context waste, cost visibility, or model efficiency problems, I'd love to hear what's missing.&lt;/p&gt;

&lt;p&gt;GitHub: github.com/atripati/ark&lt;/p&gt;

</description>
      <category>ai</category>
      <category>go</category>
      <category>machinelearning</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
