Enforce proxy budgets#19
Open
mostlydev wants to merge 1 commit into
Open
Conversation
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.
This pull request introduces a comprehensive agent-level budget policy enforcement system, allowing administrators to set and enforce usage budgets for agents. It adds support for configuring budget policies via agent metadata and governance directories, normalizes and enforces these policies at runtime, and provides detailed error responses when limits are exceeded. The changes also include new tests and configuration options to support this feature.
Budget policy enforcement and configuration:
BudgetPolicytype toagentctx, and updated agent context loading to support parsing budget policies from agent metadata (metadata.json). This enables agents to have budget constraints like max cost, max requests, time window, and enforcement behavior. [1] [2] [3] [4]GovernanceDirconfiguration and environment variable (CLAW_GOVERNANCE_DIR), allowing budget policies to be overridden or enforced centrally via governance files. The server and handler setup code was updated to accept and wire this new directory. [1] [2] [3] [4] [5] [6] [7]Budget checking and enforcement logic:
internal/proxy/budget.gomodule that normalizes, merges, and enforces budget policies, checking recent usage against limits and returning appropriate HTTP errors or soft alerts. This includes logic for loading policy overrides, handling enforcement behaviors, and integrating with session history for usage tracking.Testing and validation:
Internal API and code improvements:
These changes lay the foundation for robust, configurable budget enforcement at the agent level, supporting both soft and hard enforcement modes and centralized governance.