Level Up Your AI Agent: From Scripts to Service 🚀

· Categories: agent-framework, architecture, performance, golang

Remember those trusty discover.sh scripts? Peppered throughout our agent’s data directories, they were the go-to method for figuring out behavioral rules or finding the right cookbook recipe. Simple, effective… initially. But like that one shell alias you wrote five years ago that now takes three seconds to run (you know the one), things needed an upgrade. We’ve officially retired the scattered scripts and ushered in a new era: the centralized Go-based Agent Guidance Service. Spoiler: it’s faster, cleaner, and way easier to manage.

The Old Way: Why discover.sh Had to Go 🐢

Let’s pour one out for the discover.sh approach. It served us well, but faced growing pains:

  1. Performance Drag: Firing up a shell process for every guidance check? That adds up, especially when you need quick behavioral answers. Latency started creeping in. (Like waiting for npm install on a slow connection).
  2. Maintenance Maze: Need to tweak discovery logic? Good luck finding all the relevant scripts and updating them consistently. It was becoming a game of whack-a-mole.
  3. Brittleness: Shell scripting is powerful, but complex logic can become fragile. Testing was harder, and ensuring consistency across environments wasn’t trivial.
  4. Tight Coupling: The agent’s core logic knew too much about where and how to find these specific scripts. Changes required touching multiple layers.

The New Way: Hello, Agent Guidance Service! ✨

Enter the Agent Guidance Service, a persistent Go service acting as the central nervous system for agent guidance. Here’s the lowdown:

  1. Central Hub: Guidance data (behavior rules, recipes) lives in structured text files (Markdown + frontmatter) in known directories.
  2. Smart Watcher: The Go service monitors these files, parses them on the fly, and keeps an up-to-date index of all available guidance.
  3. API is King: The agent now talks to a simple API. The only thing it needs to know is how to curl http://localhost:8080/llm.txt (or wherever the service lives).
  4. Dynamic Protocol: That /llm.txt endpoint is magical. It delivers the entire interaction protocol the agent MUST follow. It tells the agent exactly which other API endpoints to hit (like /discover/behavior?tier=must or /discover/recipe) to get the specific information needed for its current task.
  5. Decoupled Bliss: The agent focuses on reasoning; the service handles guidance discovery and delivery. Beautiful separation of concerns! (Chef’s kiss emoji implied).

The Payoff: Performance, Flexibility, Sanity ✅

Why go through all this trouble? The benefits are substantial:

  1. Speed Demon: Replacing shell executions with cached, in-memory lookups via HTTP is fast. The agent gets guidance information almost instantly. (Think Redis vs. reading a file off a floppy disk).
  2. Flexibility++: Want to change how guidance is structured or prioritized? Update the service logic or the data files. The agent just keeps calling /llm.txt and adapts automatically because the protocol itself can be updated via that endpoint. No agent redeployment needed for protocol changes!
  3. Maintainability Wins:
    • Agent Devs: Focus on the agent, trust the /llm.txt contract.
    • Guidance Maintainers: Edit simple text files. Easy peasy.
    • Service Devs: Optimize Go code, add API features independently.
  4. Reliability & Testability: Go code lends itself to robust testing, making the whole guidance system more trustworthy than our previous script collection.

Looking Forward 🔭

This shift isn’t just about replacing scripts; it’s about building a scalable, adaptable foundation. The Agent Guidance Service allows us to evolve the agent’s interaction patterns and guidance complexity without the corresponding complexity increase in the agent’s core code. It’s an investment that makes building smarter, more reliable agents significantly easier. Now, if only we could make git conflicts this easy to resolve… (Just kidding… mostly).


This article was originally created in commit 09be77f7ebf466a0d3098b98650c85e036e3594b, prompted by commit 09be77f7ebf466a0d3098b98650c85e036e3594b.