Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-agent-github-cap-override-alone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **A per-agent GitHub API hourly cap now applies without the fleet key.** `agents.<name>.github_api_hourly_cap` was read only when `agents.github_api_hourly_cap` was also set, so `agents.reviewer.github_api_hourly_cap: 600` on its own left the reviewer at the default 300. The override now applies on its own, and a replica or review head that has none of its own takes its base agent's. `0` still means no cap at either level. See [Runtime and quota](src/docs/operator-reference/runtime-and-quota.md).
5 changes: 5 additions & 0 deletions src/docs/operator-reference/runtime-and-quota.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ loops, so the proxy enforces two safeguards:
minting is not agent-attributed and is not counted. Set the value to `0` to
disable the fleet default, or set `agents.<name>.github_api_hourly_cap` to
override one agent (`0` disables that agent's cap).
The override applies on its own, whether or not the fleet key is set. A
replica (`reviewer-2`, …) or review head takes its base agent's override
unless it has one of its own. The order is the agent's own value, then the
base agent's, then `agents.github_api_hourly_cap`, then the default of 300.
A config reload reaches the proxy without a restart.
- `github.agent_reserve_floor` (default `400`) protects the shared core bucket.
When the latest rate-limit reading shows `core.remaining` below the floor,
agent read requests receive the same proxy `429` even if the agent has not
Expand Down
20 changes: 17 additions & 3 deletions src/pkg/config/github_api_budget.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,30 @@ func mappingNode(node *yaml.Node) *yaml.Node {
return node
}

// AgentGitHubAPIHourlyCap is the per-agent proxy cap on charged GitHub API
// responses per sliding hour; 0 means no cap. An agent's own
// agents.<name>.github_api_hourly_cap wins, then its base agent's (a replica
// or review head is built as a copy of the base, so it normally carries the
// base's value already; the lookup also covers a base override set after the
// copy was made), then agents.github_api_hourly_cap, then the default of 300.
// The override used to be read only when the fleet key was set as well, so
// agents.reviewer.github_api_hourly_cap: 600 on its own left the reviewer at
// 300.
func (c *Config) AgentGitHubAPIHourlyCap(agentName string) int {
if c == nil {
return DefaultAgentsGitHubAPIHourlyCap
}
if c.AgentsGitHubAPIHourlyCap == 0 && !c.AgentsGitHubAPIHourlyCapSet {
return DefaultAgentsGitHubAPIHourlyCap
}
if a, ok := c.Agents[agentName]; ok && a.GitHubAPIHourlyCap != nil {
return *a.GitHubAPIHourlyCap
}
if base := c.BaseAgentName(agentName); base != agentName {
if a, ok := c.Agents[base]; ok && a.GitHubAPIHourlyCap != nil {
return *a.GitHubAPIHourlyCap
}
}
if c.AgentsGitHubAPIHourlyCap == 0 && !c.AgentsGitHubAPIHourlyCapSet {
return DefaultAgentsGitHubAPIHourlyCap
}
return c.AgentsGitHubAPIHourlyCap
}

Expand Down
43 changes: 43 additions & 0 deletions src/pkg/config/github_api_budget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,46 @@ agents:
t.Fatalf("cap = %d, want explicit zero", got)
}
}

// A per-agent override applies on its own: the fleet key used to be required
// too, so this left the reviewer at 300 (projectbluefin hive, 2026-11-09).
func TestGitHubAPIBudgetOverrideWithoutFleetKey(t *testing.T) {
raw := `
agents:
reviewer:
github_api_hourly_cap: 600
scanner:
enabled: true
quality:
github_api_hourly_cap: 0
`
var cfg Config
if err := yaml.NewDecoder(strings.NewReader(raw)).Decode(&cfg); err != nil {
t.Fatalf("Decode: %v", err)
}
cfg.applyDefaults()
for agent, want := range map[string]int{"reviewer": 600, "scanner": DefaultAgentsGitHubAPIHourlyCap, "quality": 0} {
if got := cfg.AgentGitHubAPIHourlyCap(agent); got != want {
t.Errorf("%s cap = %d, want %d", agent, got, want)
}
}
}

// A replica takes its base agent's override, including one set on the base
// after the replica entry was built, and its own override still wins.
func TestGitHubAPIBudgetReplicaUsesBaseOverride(t *testing.T) {
six, nine := 600, 900
cfg := &Config{AgentRuntimeConfig: AgentRuntimeConfig{Agents: map[string]AgentConfig{
"reviewer": {},
"reviewer-2": {ReplicaOf: "reviewer"},
"reviewer-3": {ReplicaOf: "reviewer", GitHubAPIHourlyCap: &nine},
}}}
reviewer := cfg.Agents["reviewer"]
reviewer.GitHubAPIHourlyCap = &six
cfg.Agents["reviewer"] = reviewer
for agent, want := range map[string]int{"reviewer": 600, "reviewer-2": 600, "reviewer-3": 900, "scanner": DefaultAgentsGitHubAPIHourlyCap} {
if got := cfg.AgentGitHubAPIHourlyCap(agent); got != want {
t.Errorf("%s cap = %d, want %d", agent, got, want)
}
}
}
Loading