Skip to content

fix(update): keep an agent's source when updating it - #778

Merged
runkids merged 3 commits into
mainfrom
runkids/agent-update-source
Nov 4, 2026
Merged

runkids merged 3 commits into
mainfrom
runkids/agent-update-source

Conversation

@runkids

@runkids runkids commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal (proposals/ only — see CONTRIBUTING.md)
  • Approved feature or large change (the linked issue has the approved label)

Linked Issue

Closes #777

What and why

After the first update agents, an agent's source was rewritten to /agents/<name>.md (type unknown-subdir, no repo_url). Without a repo URL, check agents never looks upstream, so later changes never arrived.

All three agent update paths rebuilt the repository source wrongly:

Path Problem Source written back
CLI batch (update agents --all) built a Source with only clone URL, subdir and branch; no Raw, no Type /agents/demo.md, type unknown-subdir, repo URL lost
CLI fallback reinstallAgent kept the agent's full source as Raw and cleared the subdir agent path repeated: …/agents/demo.md/agents/demo.md
Dashboard update (internal/server/handler_update.go) same as the fallback same

The new install.AgentRepoSource rebuilds the repository source once, by cutting the agent path off the recorded source, the inverse of buildDiscoverySkillSource. All three paths use it.

Tests

  • TestUpdate_Agents_RepeatedUpdatesKeepSource (integration): install from a git repo, push two changes, update twice; the second change arrives and the recorded source is unchanged. Failed before the fix with source changed from "file:///…/agents/demo.md" to "/agents/demo.md".
  • TestAgentRepoSource_RoundTripsAgentSource (unit): GitHub, SSH // and file:// sources, each as whole repo and repo subdir, round-trip to the source install recorded.
  • Manual run in the devcontainer image: whole-repo and //pack subdir installs, two updates each; source, type and repo_url unchanged, latest content arrives.
  • make check passes. After the review fixes, go vet and the internal/install, internal/server, cmd/skillshare and integration agent tests were rerun and pass.

Check fixes next to it (second commit)

Agent update checks were wrong in four related cases:

  • Agents from one repository were compared with the first agent's version, so an older agent sharing a repo with a current one never showed its update.
  • The installed branch was never sent to the remote, so an agent pinned to a non-default branch was compared with the default branch head.
  • A tracked agent repo records its full commit while the remote hash is abbreviated, so a fresh clone always read as update_available.
  • update agents printed "All agents are up to date" and exited 0 when agents could not be checked: an unreachable remote, unreadable metadata, or a source the update agents loses the agent's source, so later updates never arrive #777 bug erased.

Each agent is now compared with its own version at its own branch. Agents whose source the old bug erased report error with a reinstall hint, because their metadata no longer names a repository. update agents lists agents it could not check and exits non-zero (check agents already did). Docs in update.md, check.md and troubleshooting, plus their ja, ko, zh-Hans and zh-Hant copies, describe the error status and the reinstall fix.

Tests: TestEnrichAgentResultsWithRemote_ComparesEachAgentAtItsBranch, TestCheckAgents_SourceErasedByEarlierUpdate, TestCheckAgents_TrackedRepoComparedAtItsBranch, TestUpdate_Agents_ErasedSourceAsksToReinstall, TestUpdate_Agents_InvalidMetadataFails. Each failed before the fix. make check passes, the website builds (npm run build, rc=0), and python3 scripts/ai-context.py check passes.

Recovery and cleanup (third commit)

  • Dashboard updates before this fix appended the agent path to the source a second time (…/agents/demo.md/agents/demo.md). Those agents kept their repo URL, so check offered an update and discovery then failed. AgentRepoSource now cuts every copy of the path, and the next update writes the source back correctly (verified in the devcontainer: the agent updates and its source becomes …/agents/demo.md).
  • The dashboard showed invalid source: source cannot be empty for an agent the CLI bug erased; it now shows the same reinstall hint as check.
  • The "Checking agents" spinner was never stopped when no agent needed a remote check, and drew over the error rows.
  • The global and project update agents handlers now share one flow. The project copy had drifted: its --dry-run wrote no operation log entry, and it started the spinner under --json.

Tests: TestUpdate_Agents_LostSourceDoesNotBlockOthers (global, --json, --dry-run, project: the updatable agent still updates, the broken one is listed, exit non-zero) and TestAgentRepoSource_BrokenSources. make check passes.

Not covered

  • Agents whose metadata 0.28.x already rewrote cannot be repaired automatically; they now report an error asking for skillshare install <repo> --kind agent --all --force.
  • Two agents installed from the same repo, branch and subdir with different spellings (a GitHub tree URL and a plain path) share one group, and both are written back with the first spelling. Both spellings name the same place, so behavior is unchanged.

Checklist

  • I've read CONTRIBUTING.md, including its AI-assisted contributions section
  • I've reviewed every line of the diff and can explain it
  • Tests included and passing (make check) — for code changes
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR — the second and third commits fix agent check and recovery bugs found while fixing update agents loses the agent's source, so later updates never arrive #777; the maintainer asked for them in this PR

After the first `update agents`, an agent's recorded source became
`/agents/<name>.md` with type `unknown-subdir` and no repo URL, so
`check agents` stopped looking upstream and later changes never arrived
(#777).

The batch path rebuilt the repository source from the clone URL, subdir
and branch only, leaving Raw and Type empty, and the metadata written
back was built from that empty Raw. The fallback reinstall and the
dashboard update kept the agent's full source as Raw while clearing the
subdir, so the written source repeated the agent path.

AgentRepoSource now rebuilds the repository source once, by cutting the
agent path off the recorded source, and all three paths use it, so the
source written back is the one install recorded.

Agents whose metadata was already rewritten have no repository left in
it and need to be installed again.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-04T13:29:43.809752Z
We couldn’t complete this review. Comment @codex review to try again.
47b0cda PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

runkids added a commit that referenced this pull request Nov 4, 2026
The 0.28.4 Release PR (#767) merged, but GitHub's incident kept its
search index from listing the merged PR, so no tag or draft was made.
0.28.4 should now also ship #778, which the merged release commit
cannot include. Restoring the 0.28.3 manifest and changelog lets
Release Please open a fresh 0.28.4 Release PR over the full range.

Release-As: 0.28.4
… agents

Agent update checks gave wrong answers in several cases next to #777:

- Agents from one repository were compared with the first agent's
  version, so an older agent sharing a repo with a current one never
  showed its update.
- The installed branch was never sent to the remote, so an agent pinned
  to a non-default branch was compared with the default branch head.
- A tracked agent repo records its full commit while the remote hash is
  abbreviated, so a fresh clone always read as update_available; its
  checked-out branch was also ignored.
- `update agents` printed "All agents are up to date" and exited 0 when
  agents could not be checked at all: an unreachable remote, unreadable
  metadata, or a source erased by the #777 bug.

Each agent is now compared with its own version at its own branch, and
an agent whose source the old bug erased reports an error asking for a
reinstall, since its metadata no longer names a repository. Update lists
the agents it could not check and exits non-zero, counting them apart
from agents that failed to update. The docs describe the error status
and the reinstall fix.
…ate flow

Review of the previous commits found gaps in recovering agents that
earlier updates broke, and in how the two update handlers report them:

- A dashboard update before the #777 fix appended the agent path to its
  source a second time. Those agents keep their repo URL, so check offers
  an update, but discovery then failed on the doubled path. Every copy of
  the path is now cut, and the update writes the source back correctly.
- On the dashboard, an agent whose source the CLI bug erased failed with
  "invalid source: source cannot be empty". AgentRepoSource now returns
  the same reinstall error check shows, and both use one detector.
- When every tracked agent was such an erased agent, no remote was asked,
  so the "Checking agents" spinner was never stopped and drew over the
  error rows. It is now stopped once the check returns.
- The global and project handlers repeated the check-and-update flow,
  and the project copy had already drifted (no dry-run log entry, spinner
  in --json). Both now run one shared flow.

Tests cover the erased agent next to an updatable one in global, --json,
--dry-run and project mode, and the doubled and erased sources in
AgentRepoSource.
@runkids
runkids merged commit 53a3207 into main Nov 4, 2026
10 checks passed
@runkids
runkids deleted the runkids/agent-update-source branch November 4, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update agents loses the agent's source, so later updates never arrive

1 participant