Skip to content

πŸ› [v6] proxy cap: a per-agent GitHub API hourly cap applies without the fleet key - #17379

Merged
hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:fix/v6-agent-github-cap-override-applies
Nov 9, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:fix/v6-agent-github-cap-override-applies

Conversation

@Danathar

@Danathar Danathar commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Setting a per-agent GitHub API hourly cap on its own did nothing. agents.reviewer.github_api_hourly_cap: 600 left the reviewer at the default 300 unless the fleet key agents.github_api_hourly_cap was 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:

  1. the agent's own agents.<name>.github_api_hourly_cap;
  2. its base agent's (for a replica or review head);
  3. agents.github_api_hourly_cap;
  4. the default of 300.

0 still means no cap at either level.

Things checked, no change needed

  • Replicas already inherit on load. A replica or review head is built as a copy of the base agent's config (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.
  • A reload already reaches the proxy. The proxy's cap function is bound to the live config pointer (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 -l was 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.
  • The existing cases (fleet set with an override, explicit fleet 0, defaults, and the golden round-trip) are unchanged.

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

…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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 9, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

Conflicts are checked with every PR merged onto the current tip of v6, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#17378 πŸ› fix(proxy): An agent refused because the hive's shared GitHub budget is low is told so, with the reset time, and keeps working same files src/docs/operator-reference/runtime-and-quota.md

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 at watcher.go:137) calls cfg.applyDefaults().
  • src/pkg/config/defaults.go:128-130 β€” applyDefaults sets AgentsGitHubAPIHourlyCap = 300 whenever the fleet key is unset.
  • src/pkg/config/github_api_budget.go:154 (tip) β€” the guard is c.AgentsGitHubAPIHourlyCap == 0 && !c.AgentsGitHubAPIHourlyCapSet. After applyDefaults the cap is 300, so the condition is false and the very next statement reads agents.<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 β€” loadWithDashboardOverlay merges overlay.Agents with cfg.MergeAgentOverrides(agents).
  • src/pkg/config/agent_overlay.go:220-224 β€” MergeAgentOverrides does c.Agents[name] = agent, replacing the whole entry. The comment block at load.go:225-236 already records this exact failure for converse ("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 and TestGitHubAPIBudgetReplicaUsesBaseOverride does 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

@hivecommons-hive

hivecommons-hive Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Hive status β€” updated in place; edits do not notify. Full history is in the Activity Monitor.

Review findings from reviewer (folded here because this head already carries its hive review):

The lookup reorder is correct and complete: src/pkg/config/github_api_budget.go:150-175 now checks the agent's own override, then the base agent's (BaseAgentName, config.go:282-290), before the fleet default. Docs and changelog match the new order. Looks correct to me.

One thing in the writeup does not hold against the tree, and it affects which test actually pins the fix:

  • TestGitHubAPIBudgetOverrideWithoutFleetKey passes on the current tip. The test calls cfg.applyDefaults() (github_api_budget_test.go:80), and applyDefaults sets AgentsGitHubAPIHourlyCap = 300 whenever the fleet key is unset (src/pkg/config/defaults.go:128-130). On the tip the early return at github_api_budget.go:154 only fires when the cap is 0 and unset, so after defaults it is skipped and the per-agent override at :157 is read: reviewer=600, quality=0, not 300 as the body states. loadWithOverrides runs applyDefaults too (load.go:92), so a hive.yaml loaded normally never showed the described failure.
  • The regression is only reproducible on a Config that reaches the method without defaults β€” e.g. the direct struct in TestGitHubAPIBudgetReplicaUsesBaseOverride (which does fail on the tip), or a Snapshot() round-trip, where both fields are yaml:"-" (src/crux/config/agent_config.go:128,133) so the defaulted 300 is dropped and the tip returns 300 regardless of overrides.

Suggestion, not a blocker: drop the applyDefaults() call from the first test (or add a no-defaults case) so the headline test fails without the fix, and adjust the "On the tip, reviewer and quality both come back as 300" sentence. The new ordering is the right behaviour either way.

Evidence bundle `#17379afb4be5` sha256:ebe2176356d55693ffdd986c803c221abe43567a31efd969b991a826fad0e633 β€” download from the dashboard or `hivectl review evidence #17379`.

@hivecommons-hive
hivecommons-hive Bot merged commit d4bbc1a into hivecommons:v6 Nov 9, 2026
67 of 68 checks passed
@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @Danathar holds role owner and GitHub permission maintain on repo; CI green at afb4be5.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 != nil check now runs before the fleet-key default, and 0 at either level still returns 0 (explicit-zero test at github_api_budget_test.go:48 still covers the fleet case).
  • src/pkg/config/config.go:282-290 β€” BaseAgentName returns ReplicaOf or the name itself, so the base != agentName guard skips the second lookup for non-replicas and cannot loop.
  • src/cmd/hive/main.go:4332 passes the method value bound to b.cfg; reload at main.go:4028 does *b.cfg = *newCfg in 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

hivecommons-hive Bot added a commit that referenced this pull request Nov 9, 2026
#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant