Skip to content

agent update silently switches to default branch when adopted from a non-default ref #6674

Description

@redhat-chai-bot

Reporter: mrizzi

Problem

When adopting a URL agent from a non-default branch (e.g. release-1.0), agent add resolves the branch to a commit SHA and stores only the SHA-pinned URL in AgentEntry.Source. The original branch name is discarded.

When agent update <name> is later called without an explicit SHA, runAgentUpdate falls back to forgeClient.GetRepo().DefaultBranch (agent.go ~403-408), silently switching the agent to track the repo's default branch instead of the originally adopted one.

The command help documents this behavior ("If no SHA is provided, the default branch HEAD is used"), but for adopters tracking a stable release branch, this is surprising and incorrect — there is no warning that the tracking branch has changed.

Reproduction

  1. fullsend agent add myagent <agent-yaml-URL-on-release-1.0-branch>
  2. Agent is pinned to the SHA at the tip of release-1.0
  3. fullsend agent update myagent
  4. Agent is now pinned to the SHA at the tip of main (or whatever the repo default branch is) ✗

Root cause

  • AgentEntry (config.go) has no Ref field — only Name, Source, Enabled, Runtime, Model, Effort
  • pinAgentURL (agent.go ~527-560) resolves the branch name to a SHA and overwrites info.Ref with the SHA before building the stored URL. The original branch name is lost.
  • runAgentUpdate (agent.go ~403-408) has no stored ref to use, so it calls GetBranchRef(ctx, owner, repo, repo.DefaultBranch)

Proposed fix

Persist the adopted ref so agent update re-resolves that branch and re-pins to a fresh SHA+hash (integrity preserved):

  1. Add a Ref field to AgentEntry (persisted in YAML)
  2. agent add / pinAgentURL: store Ref: release-1.0 on the entry before overwriting info.Ref with the resolved SHA
  3. runAgentUpdate: if entry.Ref is set, call GetBranchRef(ctx, owner, repo, entry.Ref) instead of falling back to DefaultBranch
  4. Consider a --branch / --ref flag on agent update for one-off overrides

Related issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcomponent/harnessAgent harness, config, and skills loadingcustom/tsd-blockerA collection of issues that block further adoption by "tsd" users.priority/highSignificant impact, address soonready-to-codeTriaged and ready for the code agenttype/bugConfirmed defect in existing behavior

    Type

    No type

    Projects

    Status
    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions