Repository navigation
Conversation
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>
✅ Deploy Preview for theagentrouter ready!
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. OneBackendTrafficPolicyrule with aDistinctselector 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.shbuilds Substrate, Envoy Gateway and Agent Router on a kind cluster against a mock LLM, so no API keys are needed.test.shruns 6 checks: per-actor metering, a forgedx-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.shpassed 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:
mainbranch.go.mod, standard library only, so its two small programs stay out of the root module.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.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