Repository navigation
π [v6] proxy cap: a per-agent GitHub API hourly cap applies without the fleet key - #17379
Conversation
β¦he fleet key AgentGitHubAPIHourlyCap returned the default 300 whenever agents.github_api_hourly_cap was unset, before it looked at the agent's own override, so agents.reviewer.github_api_hourly_cap: 600 alone was ignored. The override is read first now, then the base agent's (for a replica or review head written before a reload re-copies the base), then the fleet key, then the default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Douglas Baggett <doug.baggett@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
The stated root cause does not hold on a loaded config, so the new test does not fail on v6 tip and the projectbluefin symptom is probably somewhere else. Flagging rather than blocking: the code change itself is harmless.
Why the old guard was inert
src/pkg/config/load.go:92β every production load (Load,LoadWithOverrides,LoadWithDashboardOverlayβloadWithOverrides, which is also what the config watcher uses atwatcher.go:137) callscfg.applyDefaults().src/pkg/config/defaults.go:128-130βapplyDefaultssetsAgentsGitHubAPIHourlyCap = 300whenever the fleet key is unset.src/pkg/config/github_api_budget.go:154(tip) β the guard isc.AgentsGitHubAPIHourlyCap == 0 && !c.AgentsGitHubAPIHourlyCapSet. AfterapplyDefaultsthe cap is 300, so the condition is false and the very next statement readsagents.<name>.github_api_hourly_cap. The per-agent override was already honoured.
TestGitHubAPIBudgetOverrideWithoutFleetKey calls cfg.applyDefaults() before asserting, so on tip reviewer=600 and quality=0 come back as expected and the test passes β contrary to the PR body's "On the tip, reviewer and quality both come back as 300". The only case where the old guard fired is a Config that never went through applyDefaults (hand-built structs in tests). Worth re-checking the test claim in CI by running it against tip before merging on the strength of it.
Where the projectbluefin reviewer likely loses its 600
The body says this is for a hub-managed spoke. On that path the agent entry comes through the dashboard overlay:
src/pkg/config/load.go:225-243βloadWithDashboardOverlaymergesoverlay.Agentswithcfg.MergeAgentOverrides(agents).src/pkg/config/agent_overlay.go:220-224βMergeAgentOverridesdoesc.Agents[name] = agent, replacing the whole entry. The comment block atload.go:225-236already records this exact failure forconverse("MergeAgentOverrides replaces the whole entry β¦ was dropped on every boot and reload") and special-cases it.
So agents.reviewer.github_api_hourly_cap: 600 in the seed hive.yaml is dropped whenever the overlay carries a reviewer entry without that key, and the proxy sees nil β fleet default 300. This PR's reordering does nothing for that case. If that is the real bug, the fix belongs next to the Converse carry-forward (or in keepHandSetBackend), with a test that builds the overlay layer.
What is fine
- The new base-agent fallback (
BaseAgentName,config.go:282-290) is a correct, additive behaviour andTestGitHubAPIBudgetReplicaUsesBaseOverridedoes exercise it. - Reordering the guard after the per-agent lookup is behaviour-preserving for loaded configs.
Suggest: either retitle/rescope this as "replica takes its base agent's cap override" with the body corrected, or chase the overlay path. I have not run anything locally per AGENTS.md; the reasoning above is from reading the files at the cited lines.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from The lookup reorder is correct and complete: One thing in the writeup does not hold against the tree, and it affects which test actually pins the fix:
Suggestion, not a blocker: drop the |
There was a problem hiding this comment.
Looks correct to me. Read AgentGitHubAPIHourlyCap against the v6 tree and its one consumer.
src/pkg/config/github_api_budget.go:160-172β the reorder is the whole fix: the per-agent!= nilcheck now runs before the fleet-key default, and0at either level still returns0(explicit-zero test atgithub_api_budget_test.go:48still covers the fleet case).src/pkg/config/config.go:282-290βBaseAgentNamereturnsReplicaOfor the name itself, so thebase != agentNameguard skips the second lookup for non-replicas and cannot loop.src/cmd/hive/main.go:4332passes the method value bound tob.cfg; reload atmain.go:4028does*b.cfg = *newCfgin place, so the new doc sentence "a config reload reaches the proxy without a restart" is accurate.- The two new tests fail against the old ordering (reviewer would read 300, not 600).
No security or scope concerns; changelog fragment and operator-reference paragraph match the behaviour.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
#17379 said a per-agent agents.<name>.github_api_hourly_cap was ignored without the fleet key. It was not: every load runs applyDefaults, which fills the fleet value in, so the old guard never fired on a loaded config (hive reviewer on #17379). What #17379 adds is the base-agent fallback for replicas and review heads. The changelog note and comments now say that. Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Douglas Baggett <doug.baggett@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Summary
Setting a per-agent GitHub API hourly cap on its own did nothing.
agents.reviewer.github_api_hourly_cap: 600left the reviewer at the default 300 unless the fleet keyagents.github_api_hourly_capwas also set. The override now applies on its own. This is part 1 of making the reviewer's cap settable on a hub-managed spoke; the dashboard control and admin MCP write op follow in a separate PR.What went wrong
AgentGitHubAPIHourlyCap(src/pkg/config/github_api_budget.go:150-161) returned the default whenever the fleet key was unset, before it looked at the agent's own override. The operator reference says an override works per agent, and it didn't.On the projectbluefin hive the reviewer reaches its 300/h cap overnight, and its reviews after the cap come back as false "requires human". The planned fix there, a reviewer-only override of 600, would have been silently ignored.
What changes
The lookup order is now:
agents.<name>.github_api_hourly_cap;agents.github_api_hourly_cap;0still means no cap at either level.Things checked, no change needed
config.go:372,review_heads.go:74), so it carries the base's override. The base-agent step covers an override written to the base later, before a reload copies it again. A replica's own value still wins.main.go:4332), and the reload swaps that config in place (*b.cfg = *newCfg,main.go:4028). So a changed cap applies on the next reload, with no restart.Files
src/pkg/config/github_api_budget.go: the lookup order.src/pkg/config/github_api_budget_test.go: two tests.src/docs/operator-reference/runtime-and-quota.md: the order, replicas and live apply.changelog.d/fixed-agent-github-cap-override-alone.md.Tests
CI is the verdict. Only
gofmt -lwas run locally.TestGitHubAPIBudgetOverrideWithoutFleetKey: with the fleet key unset, reviewer=600, scanner=300 and quality=0. On the tip, reviewer and quality both come back as 300.TestGitHubAPIBudgetReplicaUsesBaseOverride: reviewer-2 gets the base reviewer's 600, reviewer-3's own 900 wins, and an unrelated agent gets 300.π€ Generated with Claude Code
https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1