Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: I got tired of "Reliability Spaghetti," so I monkeypatched PydanticAI
2 points by steer_dev 61 days ago | hide | past | favorite
Author of the "Confident Idiot" post here (https://news.ycombinator.com/item?id=46152838).

After that discussion, I looked at my own agent code and realized it was 80% error handling and 20% reasoning. I was manually decorating every function with retries, regex checks, and JSON validators. It was unreadable.

I realized that reliability shouldn't be Application Code; it should be Infrastructure.

I built Steer to test a pattern: Monkeypatching the framework to decouple reliability.

Instead of decorating functions, I initialize Steer at the entry point. It hooks into the framework's lifecycle (PydanticAI / OpenAI), introspects the tools, and attaches "Reality Locks" (SQL parsers, Schema checks, Entropy filters) globally.

Before (The Spaghetti):

  # Business logic mixed with safety logic
  @retry(stop=stop_after_attempt(3))
  def run_query(q):
      if "DROP" in q: raise Error() # Manual check
      response = agent.run(q)
      if not is_valid_sql(response): raise Error() # Manual check
      return response
After (The Mesh):

  import steer
  # One line patches the framework globally.
  # Auto-attaches SQL validators to any tool returning SQL.
  steer.init(patch=["pydantic_ai"], policy="strict_sql")

  # Pure Business Logic
  agent.run(query)
It currently handles SQL AST validation, PII redaction, and a "Slop Filter" (using Shannon Entropy to block apologies).

It’s open source and local-first. I’m curious if anyone else is using this "sidecar" pattern or if you prefer explicit middleware?

Repo: https://github.com/imtt-dev/steer



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: