Skip to content

πŸ› scheduler: fetch AGENTS.md from GitHub when a hosted spoke has no local checkout - #17093

Merged
clubanderson merged 1 commit into
v5from
fix/agentsmd-hosted-fallback
Nov 7, 2026
Merged

clubanderson merged 1 commit into
v5from
fix/agentsmd-hosted-fallback

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Fixes #17090

Problem

A hosted spoke keeps no clone of its primary repo, so both roots agentsRepoRoot() knows β€” project.checkouts_dir and a policies.local_dir that matches the repo β€” are empty and primeAgentsMd("") is a silent no-op. Hive's own hive (hive-hosted-…-r05x, branch v5) shows zero agentsmd: log lines over hours of kicks. Pointing policies.repo at the primary repo is not a safe workaround: loadPromptTemplate would then read <local_dir>/examples/kubestellar/agents/<agent>.md as kick templates.

Fix

Third source in agentsRepoRoot, used only when neither local root is configured and a GitHub client is wired (Scheduler.SetAgentsMdFetcher, set at boot from b.ghClient):

  • fetch AGENTS.md from the repo's default branch via GetFileContentRef on the shared pkg/github client (the ETag transport makes refreshes of an unchanged file free);
  • cache per owner/repo for 15 min, negative-cache a 404, and keep serving the last-known-good copy when a refresh fails;
  • materialise it under /data/agentsmd-cache/<owner>/<repo>/AGENTS.md so agentsmd.Parse, Render (existing project.agents_md_max_bytes cap), primeSkills and the house-style path all run unchanged, and the existing agentsmd: injecting repo instructions into kick root=… line now says where the text came from.

No behaviour change for hives that do have a local root, or that run without a GitHub client.

Tests

src/pkg/scheduler/kick_priming_test.go: no fetcher β†’ unchanged; fetch + inject + single call inside TTL; 404 negative cache + last-known-good on later failure; local root still wins (no fetch).

Checklist

  • changelog fragment: changelog.d/fixed-agentsmd-hosted-fallback.md
  • DCO sign-off

…ocal checkout

Hosted spokes keep no clone of their primary repo, so both roots
agentsRepoRoot knows (project.checkouts_dir, policies.local_dir) are empty
and primeAgentsMd was a silent no-op: hive's own hive showed zero agentsmd:
log lines. Add a third source: when no local root exists and a GitHub
client is wired, fetch AGENTS.md from the repo's default branch, cache it
for 15 minutes (the conditional-GET transport makes refreshes free), keep
the last-known-good copy across API failures, and materialise it under
/data/agentsmd-cache/<owner>/<repo>/ so Parse/Render/primeSkills and the
injection cap run unchanged.

Fixes #17090

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 7, 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 hanthor 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

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

PR Title Relation Files
#17086 ✨ agents: drain CLI memory into draft knowledge entries before clearing same files src/cmd/hive/main.go
#17079 ✨ knowledge: prime an agent's own drafts when agent_scopes.include_states lists draft same files src/pkg/scheduler/kick_priming.go

@clubanderson
clubanderson merged commit 21bd634 into v5 Nov 7, 2026
83 of 86 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/agentsmd-hosted-fallback branch November 7, 2026 19:59
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

πŸ› hosted spokes never inject AGENTS.md: no checkout and no policies.repo default

1 participant