Skip to content

examples: add per-agent token budgets for Agent Substrate - #2990

Draft
missBerg wants to merge 1 commit into
theagentrouter:mainfrom
missBerg:examples/agent-substrate
Draft

missBerg wants to merge 1 commit into
theagentrouter:mainfrom
missBerg:examples/agent-substrate

Conversation

@missBerg

@missBerg missBerg commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Description

This adds an example, a docs page and a blog post showing per-agent token budgets for agents that run on Agent Substrate [1]. It uses configuration only, with no changes to Agent Router or Substrate and no extra services.

Substrate's egress gateway puts a short-lived JWT that names the actor on each outbound request. Agent Router verifies the token against Substrate's keys and copies the subject to x-actor-id. One BackendTrafficPolicy rule with a Distinct selector on that header gives every actor its own token bucket, charged with the token count Agent Router reads from each response. Agents hold no provider key.

  • examples/agent-substrate: setup.sh builds Substrate, Envoy Gateway and Agent Router on a kind cluster against a mock LLM, so no API keys are needed. test.sh runs 6 checks: per-actor metering, a forged x-actor-id, budget exhaustion with another actor unaffected, an actor with no egress rule, a pod that isn't an actor, and streaming.
  • site/docs/capabilities/traffic/agent-substrate.md: the setup steps and limitations.
  • site/blog/2026/2026-11-06-agent-substrate-token-budgets.md: the blog post and its social image.

1: https://github.com/agent-substrate/substrate

Related Issues/PRs (if applicable)

N/A

Special notes for reviewers (if applicable)

To try it: cd examples/agent-substrate && ./setup.sh && ./test.sh. It needs Docker and about 15 GB of free disk, and takes 3 to 7 minutes with warm build caches because it builds Substrate from source.

Tested with Agent Router v1.2.1 and Envoy Gateway v1.9.3, on Docker Desktop on Apple Silicon. test.sh passed on repeated runs from a clean cluster. Not tested on Linux, on a machine with cold build caches, or against a real model provider, and the example isn't wired into CI.

Things to check:

  • Substrate is pre-1.0, so the example pins a commit from its main branch.
  • The example has its own go.mod, standard library only, so its two small programs stay out of the root module.
  • The docs page is only in site/docs, so the post links to /docs/next/. The example runs on released versions, so it could also be backported to the 1.2 docs.
  • Merging publishes the post, and the post links to the example on main, so they ship together. If it goes out later, rename the file and regenerate the social image, which shows the date: npm run og:generate -- --slug agent-substrate-token-budgets.

Written with Claude Code.

🤖 Generated with Claude Code [2]

2: https://claude.com/claude-code

Adds an example, a docs page and a blog post showing per-agent token
budgets for agents that run on Agent Substrate, using configuration only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Erica Hughberg <erica.sundberg.90@gmail.com>
@netlify

netlify Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for theagentrouter ready!

Name Link
🔨 Latest commit fc04685
🔍 Latest deploy log https://app.netlify.com/projects/theagentrouter/deploys/6aee17cc3c4fa1ecd4bd4f4f
😎 Deploy Preview https://deploy-preview-2990--theagentrouter.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

// inside this process, so the numbers exclude the ingress path used to reach
// the actor.
func bench(ctx context.Context, n int, req callRequest) map[string]any {
lat := make([]float64, 0, n)
@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants