Skip to content

fix(push): preserve placed-agent history during format conversion - #1339

Merged
SaulMoro merged 22 commits into
Tencent:mainfrom
nateEc:fix/1326-agent-format-history
Oct 26, 2026
Merged

SaulMoro merged 22 commits into
Tencent:mainfrom
nateEc:fix/1326-agent-format-history

Conversation

@nateEc

@nateEc nateEc commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

In self mode, converting a placed agent from Markdown to YAML could be rejected after the author's own merge; a deleted placed agent could also be accidentally published again. Record the proven delivered source blob from Git history and use that evidence to distinguish a completed placement, a real upstream edit and retired copies. Shared-root re-additions clear retired records; namespaced re-additions get an explicit canonical-source recovery path.

Review follow-up:

Protect format conversions against teammate changes even when the checkout is fully synchronized, by comparing the default-branch blob of the retired file with the blob this machine last saw. Reject edited leftover tool copies as new shared-root agents. A namespaced source recreated by the team remains a distinct source: the warning names its exact path and directs the member to edit that canonical source after updating the checkout, while keeping retired flattened copies as backups. Older records explain their missing delivered-blob evidence. Remove unnecessary narrowing assertions.

Second and third review follow-ups:

  • A conversion over a teammate's edit now goes through only with an explicit acknowledgment. The member's root copy is never refreshed from the team file, so a push cannot tell from the files whether a .yaml carries an edit made to the .md. The stop prints teamai push --carried <path>@<blob>, naming the retired file and its current blob on the default branch. With that value the push deletes the file only while the default branch still holds that blob; a later team edit stops it again and prints the new value. Without it every retry stops, as the other conflict guards do. A value that names no stopped conversion is rejected.
  • Nothing is written to state for this. A failed push, a dry run, or another linked worktree of the same project (they share one state partition) cannot let a push through without its own --carried. An earlier revision recorded the blob a stop named, which let an unchanged retry delete the teammate's edit; that is removed. Updating the record on pull was not used either: a member who runs teamai pull and then converts the old root copy would delete the edit with no stop.
  • --carried is repeatable, regenerated into skill-data/core/references/commands.md. An older placement record without a delivered blob keeps the plain "pull, carry, push again" message: once the checkout is up to date, it no longer stops. The docs say such records catch a team edit only while the checkout is behind it.
  • Merged main (4cb2b3c1). The troubleshooting.md conflicts keep every section.

Fourth review follow-up:

  • --carried waives only the deletion it names. The check for the file a conversion would delete no longer skips the source and destination checks for the same item. A teammate's file at the conversion's destination (for example agents/ops/sample.yaml added next to the .md) still stops the push with the usual "changed both here and on origin/main" message. Before, the carried push replaced that file.
  • --carried is checked against the conversions this push sends. A value for a conversion that --skill or the selection leaves out is rejected. So is any value on a push with no resource to send, including a teamai.yaml-only push and pushes outside single-repo mode. Before, those exited 0 or published the config branch.

Fifth follow-up, an edited placed agent (the same gap exists on main):

  • An edit of a placed agent's root copy is now checked the way a conversion is. In single-repo mode the member's root copy of an agent placed in a namespace is pushed over the placed file. When the checkout was up to date with main, nothing compared that file with what this machine had delivered, so a teammate's change to agents/ops/<name>.md was overwritten without a stop. The same happened after the "Merge origin/main" advice: the team file and the root copy are different paths, so git shows no conflict. The push now compares the placed file's blob on main with the delivered blob. When they differ it stops with exit 2 (... would overwrite .teamai/agents/ops/sample.md, which changed on origin/main since this machine delivered it ...) and prints the --carried <path>@<blob> value. --carried follows the same rules as for a deletion: exact current blob, only for items going out, nothing stored. A record without a delivered blob behaves as before until its first merged edit (sixth follow-up).
  • The delivered blob now follows this machine's own merged edits. It used to be written only when a placement or conversion landed. So once the member's own edit had merged, their next conversion stopped as if a teammate had changed the file, and the new overwrite check would have stopped their next edit the same way. An edit pushed through a record that has a delivered blob now records its blob when it lands, as edits of repo-backed placements already do.
  • --carried help (regenerated commands.md), the docs in both languages and troubleshooting.md now cover both cases. The rejection message now reads names no placed agent file this push stops for; the earlier records below show the previous wording.
  • Merged main (97a762ce).

Sixth follow-up, agents placed by an earlier release:

  • A placement record written before this PR has the agent's path but no delivered blob. Its edits never carried one, so the overwrite stop above never applied to it, and only a format conversion gave it a blob. That covers every agent placed before this release. An edit pushed through such a record is now marked as a placement, and the record takes that edit's blob once it lands. From then on the overwrite stop applies. Nothing new stops on that first push, and nothing is recorded before it merges.
  • The docs in both languages and troubleshooting.md now say the first merged edit gives an older record its blob.

Test Plan

  • npx tsc --noEmit, npm run lint, npm run build, git diff --check origin/main...HEAD: passed.

  • Focused unit files (agents, placement-records, pull-placement-reconcile, self-mode-push-scan, push-all-resources-namespaces, push-role, commands-reference): 222 passed.

  • npx vitest run: 16476 passed, 21 skipped, 4 failed, all timeouts in workflow-reconciliation.test.ts and workflow-settle-cost.test.ts while a real-CLI run went alongside. Those two files alone: 13 passed. Neither is touched here.

  • After build, npm run test:e2e -- self-mode-push-behind, push-active-namespaces, role-scoped-agents, namespaced-entries, ownership-rules-agents-993: 146 passed. The new case deletes a placed agent a teammate changed only with --carried naming the version the stop printed failed before the fix: its unchanged retry exited 1 with Pushed branch instead of 2. It covers the dry-run stop, two unchanged retries, a value naming another path, an outdated value after a second team edit, a dry run with the value, and the carried push.

  • Cases added in the fourth follow-up, each run against the previous head before its fix: stops a --carried agent conversion when a teammate added its destination file (exited 1 with Pushed branch instead of 2), rejects --carried for an agent conversion this push leaves out (exited 1 with Pushed branch), rejects --carried when no resource goes out, teamai.yaml changed: false (exited 0) and : true (exited 1 with Pushed branch).

  • Cases added in the fifth follow-up, each run against the head before its fix: pushes the next conversion of a placed agent after this machine's own edit landed (stopped with the false would delete ... since this machine delivered it), and overwrites a placed agent a teammate changed only with --carried naming the version the stop printed (its first dry run exited 0 instead of 2). pushes the next edit of a placed agent after this machine's own edit landed passed before, and failed with the overwrite check alone until the delivered blob followed the member's merged edit.

  • Case added in the sixth follow-up, run against the previous head before its fix: stops an edit over a teammate's change once an older placement record took the blob of a merged edit (its push exited 1 with Pushed branch instead of 2).

  • Real CLI for the sixth follow-up: self mode, local bare remote, isolated HOME and git config, the same script on the previous head (762a11cd) and on the new head. The member places agents/ops/sample.md and it merges. placedAgentSources is then removed from the state, as a record from an earlier release has none. The member edits the root copy, and that edit merges. A teammate then edits the placed file (blob B). The member runs git pull and edits the root copy without B.

    Before (762a11cd):

    # 2. first edit through the older record, pushed and merged
    state after merge: {"placedAgents":{"sample":"agents/ops/sample.md"},"placedAgentSources":"(absent)"}  tip=3ce6a86cc094c284bdbad6eaa8cbed443cfaddd5
    # 3. after the teammate's edit and git pull
    $ teamai push --all --role ops --dry-run
    ℹ Dry run — no changes made
    exit 0
    $ teamai push --all --role ops
    ✔ Pushed branch teamai/push/member/20261026-154841
    exit 1
    pushed ops/sample.md lines with Teammate: 0, with Second member edit: 1
    

    After:

    # 2. first edit through the older record: no stop, nothing recorded until it merges
    $ teamai push --all --role ops
    ✔ Pushed branch teamai/push/member/20261026-154857
    exit 1
    state before merge: {"placedAgents":{"sample":"agents/ops/sample.md"},"placedAgentSources":"(absent)"}
    state after merge: {"placedAgents":{"sample":"agents/ops/sample.md"},"placedAgentSources":{"sample":{"path":"agents/ops/sample.md","blob":"3ce6a86cc094c284bdbad6eaa8cbed443cfaddd5"}}}  tip=3ce6a86cc094c284bdbad6eaa8cbed443cfaddd5
    # 3. after the teammate's edit (B=37ab5fb5d073504698ed1cb706e95cf392034f6a) and git pull
    $ teamai push --all --role ops --dry-run
    ✖ .teamai/agents/sample.md (pushed to .teamai/agents/ops/sample.md) would overwrite .teamai/agents/ops/sample.md, which changed on origin/main since this machine delivered it. Nothing was pushed. Run `git pull origin main`, carry that change into .teamai/agents/sample.md, then run `teamai push --carried .teamai/agents/ops/sample.md@37ab5fb5d073504698ed1cb706e95cf392034f6a` with the other options you used. --carried accepts only this version of that file.
    exit 2
    $ teamai push --all --role ops
    ✖ [same message]
    exit 2
    push branches: []
    # 4. member carries B's line in and names that version
    $ teamai push --all --role ops --carried .teamai/agents/ops/sample.md@37ab5fb5d073504698ed1cb706e95cf392034f6a
    ✔ Pushed branch teamai/push/member/20261026-154905
    exit 1
    pushed ops/sample.md lines with Teammate: 1, with Second member edit: 1
    
  • Real CLI for the fifth follow-up: self mode, local bare remote, isolated HOME and git config, the same script on this branch merged with main and on the new head. The member places agents/ops/sample.md, then makes two edits of the root copy, each merged. A teammate then edits the placed file (blob B). The member edits the root copy without B.

    Before (merge commit 8c19056f):

    # 2. after the member's own edit merged, the delivered blob is still the first placement's
    delivered after own edit merged: {"sample":{"path":"agents/ops/sample.md","blob":"6299714ca704b5cc42ecd631d18a822ee902cbe7"}}  (ops/sample.md on main: 3ce6a86cc094c284bdbad6eaa8cbed443cfaddd5)
    # 5. member runs git pull (the advice of the "changed both here" stop), then pushes
    $ teamai push --all --role ops --dry-run
    ℹ Dry run — no changes made
    exit 0
    $ teamai push --all --role ops
    ✔ Pushed branch teamai/push/member/20261026-151457
    exit 1
    $ git show teamai/push/member/20261026-151457:.teamai/agents/ops/sample.md | grep -c Teammate
    0
    

    After:

    # 2. after the member's own edit merged, the delivered blob follows it; the next edit pushes
    delivered after own edit merged: {"sample":{"path":"agents/ops/sample.md","blob":"3ce6a86cc094c284bdbad6eaa8cbed443cfaddd5"}}  (ops/sample.md on main: 3ce6a86cc094c284bdbad6eaa8cbed443cfaddd5)
    $ teamai push --all --role ops
    ✔ Pushed branch teamai/push/member/20261026-151514
    exit 1
    # 3. teammate edits ops/sample.md (B); the member's copy is unchanged
    $ teamai push --all --role ops --dry-run
    ⚠ [agents] Skipped sample: .teamai/agents/sample.md is an older version of agents/ops/sample.md, which has changed on the team since. Copy the current file over it (or delete it) before editing.
    ℹ No new or modified resources to push
    exit 0
    # 4. member edits the copy without B, checkout behind B
    $ teamai push --all --role ops
    ✖ .teamai/agents/sample.md (pushed to .teamai/agents/ops/sample.md) changed both here and on origin/main since this checkout branched from it, so pushing would overwrite that change. Nothing was pushed. Merge origin/main (`git pull origin main`), resolve any conflict, then push again.
    ✖ .teamai/agents/sample.md (pushed to .teamai/agents/ops/sample.md) would overwrite .teamai/agents/ops/sample.md, which changed on origin/main since this machine delivered it. Nothing was pushed. Run `git pull origin main`, carry that change into .teamai/agents/sample.md, then run `teamai push --carried .teamai/agents/ops/sample.md@8edc191c2686e2e16f912f23cdb7da0ed2ba970d` with the other options you used. --carried accepts only this version of that file.
    exit 2
    # 5. after git pull: dry run, push and a plain retry all stop
    $ teamai push --all --role ops --dry-run
    ✖ .teamai/agents/sample.md (pushed to .teamai/agents/ops/sample.md) would overwrite .teamai/agents/ops/sample.md, which changed on origin/main since this machine delivered it. [...] `teamai push --carried .teamai/agents/ops/sample.md@8edc191c2686e2e16f912f23cdb7da0ed2ba970d` [...]
    exit 2
    $ teamai push --all --role ops
    ✖ [same message]
    exit 2
    $ teamai push --all --role ops
    ✖ [same message]
    exit 2
    push branches: []
    # 6. teammate edits again (C); the old value and a value for another path are refused
    $ teamai push --all --role ops --carried .teamai/agents/ops/sample.md@8edc191c2686e2e16f912f23cdb7da0ed2ba970d
    ✖ .teamai/agents/sample.md (pushed to .teamai/agents/ops/sample.md) would overwrite .teamai/agents/ops/sample.md, [...] `teamai push --carried .teamai/agents/ops/sample.md@273b2e213c5963f6b4295a3079b616709788dde9` [...]
    exit 2
    $ teamai push --all --role ops --carried .teamai/agents/ops/other.md@273b2e213c5963f6b4295a3079b616709788dde9
    ✖ --carried .teamai/agents/ops/other.md@273b2e213c5963f6b4295a3079b616709788dde9 names no placed agent file this push stops for. Nothing was pushed. Pass the <path>@<blob> value a push stop printed, or push without --carried.
    exit 2
    push branches: []
    # 7. member pulls and carries B and C; a dry run with the value, a plain retry, then the value
    $ teamai push --all --role ops --carried .teamai/agents/ops/sample.md@273b2e213c5963f6b4295a3079b616709788dde9 --dry-run
    ℹ Dry run — no changes made
    exit 0
    push branches: []
    $ teamai push --all --role ops
    ✖ .teamai/agents/sample.md (pushed to .teamai/agents/ops/sample.md) would overwrite .teamai/agents/ops/sample.md, [...]
    exit 2
    $ teamai push --all --role ops --carried .teamai/agents/ops/sample.md@273b2e213c5963f6b4295a3079b616709788dde9
    ✔ Pushed branch teamai/push/member/20261026-151525
    exit 1
    $ git show teamai/push/member/20261026-151525:.teamai/agents/ops/sample.md
    ---
    name: sample
    description: A sample agent
    ---
    
    Sample instructions.
    First member edit.
    Second member edit.
    Teammate safety instructions.
    Teammate review step.
    Member instructions.
    

    [...] marks the repeated tail of the same message.

  • Real CLI, self mode, local bare remote, isolated HOME and git config. The member places agents/ops/sample.md with push --all --role ops and the team merges it. A teammate then edits it on main. The member deletes .teamai/agents/sample.md and writes .teamai/agents/sample.yaml from the old copy, without the teammate's line.

    Before the fix (this branch merged with main), the unchanged retry deletes the teammate's edit:

    B=8274783054d18fdb26fa7bd732c0a4a0e4373c3d
    $ teamai push --all --role ops --dry-run
    ✖ .teamai/agents/sample.yaml (pushed to .teamai/agents/ops/sample.yaml) would delete .teamai/agents/ops/sample.md, which changed on origin/main since this machine last saw it. Nothing was pushed. Run `git pull origin main`, carry that change into .teamai/agents/sample.yaml, then push again.
    exit 2
    $ teamai push --all --role ops
    ✖ .teamai/agents/sample.yaml (pushed to .teamai/agents/ops/sample.yaml) would delete .teamai/agents/ops/sample.md, which changed on origin/main since this machine last saw it. Nothing was pushed. Run `git pull origin main`, carry that change into .teamai/agents/sample.yaml, then push again. The next push does not stop for this version again.
    exit 2
    # 3. unchanged retry
    $ teamai push --all --role ops
    ✔ Pushed branch teamai/push/member/20261026-134540
    exit 1
    push branches: [teamai/push/member/20261026-134540]
    $ git diff --name-status main teamai/push/member/20261026-134540
    D	.teamai/agents/ops/sample.md
    A	.teamai/agents/ops/sample.yaml
    $ git show teamai/push/member/20261026-134540:.teamai/agents/ops/sample.yaml
    name: sample
    description: A sample agent
    instructions: Member replacement instructions.
    

    After:

    B=8274783054d18fdb26fa7bd732c0a4a0e4373c3d
    $ teamai push --all --role ops --dry-run
    ✖ .teamai/agents/sample.yaml (pushed to .teamai/agents/ops/sample.yaml) would delete .teamai/agents/ops/sample.md, which changed on origin/main since this machine delivered it. Nothing was pushed. Run `git pull origin main`, carry that change into .teamai/agents/sample.yaml, then run `teamai push --carried .teamai/agents/ops/sample.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d` with the other options you used. --carried accepts only this version of that file.
    exit 2
    $ teamai push --all --role ops
    ✖ .teamai/agents/sample.yaml (pushed to .teamai/agents/ops/sample.yaml) would delete .teamai/agents/ops/sample.md, which changed on origin/main since this machine delivered it. Nothing was pushed. Run `git pull origin main`, carry that change into .teamai/agents/sample.yaml, then run `teamai push --carried .teamai/agents/ops/sample.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d` with the other options you used. --carried accepts only this version of that file.
    exit 2
    # 3. unchanged retry
    $ teamai push --all --role ops
    ✖ .teamai/agents/sample.yaml (pushed to .teamai/agents/ops/sample.yaml) would delete .teamai/agents/ops/sample.md, which changed on origin/main since this machine delivered it. Nothing was pushed. Run `git pull origin main`, carry that change into .teamai/agents/sample.yaml, then run `teamai push --carried .teamai/agents/ops/sample.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d` with the other options you used. --carried accepts only this version of that file.
    exit 2
    push branches: []
    # 4. --carried naming a path no stop named
    $ teamai push --all --role ops --carried .teamai/agents/ops/other.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d
    ✖ --carried .teamai/agents/ops/other.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d names no agent conversion this push stops for. Nothing was pushed. Pass the <path>@<blob> value a push stop printed, or push without --carried.
    exit 2
    # 5. teammate edits again (blob C); member reuses the old value
    C=bd53c6a777ecd9f0c27e14930d432124864d9926
    $ teamai push --all --role ops --carried .teamai/agents/ops/sample.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d
    ✖ .teamai/agents/sample.yaml (pushed to .teamai/agents/ops/sample.yaml) would delete .teamai/agents/ops/sample.md, which changed on origin/main since this machine delivered it. Nothing was pushed. Run `git pull origin main`, carry that change into .teamai/agents/sample.yaml, then run `teamai push --carried .teamai/agents/ops/sample.md@bd53c6a777ecd9f0c27e14930d432124864d9926` with the other options you used. --carried accepts only this version of that file.
    exit 2
    push branches: []
    # 6. member pulls, carries C, previews, then pushes with the printed value
    $ teamai push --all --role ops --carried .teamai/agents/ops/sample.md@bd53c6a777ecd9f0c27e14930d432124864d9926 --dry-run
    ℹ Dry run — no changes made
    exit 0
    push branches after dry run: []
    $ teamai push --all --role ops --carried .teamai/agents/ops/sample.md@bd53c6a777ecd9f0c27e14930d432124864d9926
    ✔ Pushed branch teamai/push/member/20261026-140108
    exit 1
    $ git diff --name-status main teamai/push/member/20261026-140108
    D	.teamai/agents/ops/sample.md
    A	.teamai/agents/ops/sample.yaml
    $ git show teamai/push/member/20261026-140108:.teamai/agents/ops/sample.yaml
    name: sample
    description: A sample agent
    instructions: |
      Member replacement instructions.
      Teammate safety instructions.
      Teammate review step.
    # 7. linked worktree of the same project (shared partition) converts its own stale copy without --carried
    $ teamai push --all --role ops
    Found 1 resource(s) to push:
        1. [agents] sample (modified)
           awaiting review: branch teamai/push/member/20261026-140108
    ℹ 1 resource(s) already belong to an open PR. Keeping them selected updates that PR instead of opening a duplicate; deselect them to leave it untouched.
    ✖ .teamai/agents/sample.yaml (pushed to .teamai/agents/ops/sample.yaml) would delete .teamai/agents/ops/sample.md, which changed on origin/main since this machine delivered it. Nothing was pushed. Run `git pull origin main`, carry that change into .teamai/agents/sample.yaml, then run `teamai push --carried .teamai/agents/ops/sample.md@bd53c6a777ecd9f0c27e14930d432124864d9926` with the other options you used. --carried accepts only this version of that file.
    exit 2
    push branches: [teamai/push/member/20261026-140108]
    

    Exit 1 after Pushed branch comes from the git provider, which cannot open a PR. The existing e2e expects the same. Step 7 is a linked worktree of the same project, which shares the state partition; its stale conversion would have updated the open PR.

  • Real CLI for the fourth follow-up, same setup, the same script run on the previous head and on this one. After the placement merges, a teammate edits agents/ops/sample.md (blob B) and adds agents/ops/sample.yaml. The member, still behind, converts its root copy and carries the .md edit. Steps 1, 2 and 7 run with nothing else to push.

    Before (d275d972):

    # 1. nothing to push
    $ teamai push --all --carried nonsense
    ℹ No new or modified resources to push
    exit 0
    # 2. only teamai.yaml changed
    $ teamai push --all --carried nonsense
    ✔ Pushed branch teamai/push/member/20261026-143328
    exit 1
    # 4. carried conversion over the teammate's new YAML
    $ teamai push --all --role ops --carried .teamai/agents/ops/sample.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d --dry-run
    ℹ Dry run — no changes made
    exit 0
    $ teamai push --all --role ops --carried .teamai/agents/ops/sample.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d
    ✔ Pushed branch teamai/push/member/20261026-143334
    exit 1
    $ git diff --name-status main teamai/push/member/20261026-143334
    D	.teamai/agents/ops/sample.md
    M	.teamai/agents/ops/sample.yaml
    $ git show teamai/push/member/20261026-143334:.teamai/agents/ops/sample.yaml
    name: sample
    description: A sample agent
    instructions: |
      Member replacement instructions.
      Teammate safety instructions.
    # 5. --skill sends an unrelated skill, with the conversion's value
    $ teamai push --all --skill .teamai/skills/independent --shared --carried .teamai/agents/ops/sample.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d
    ✔ Pushed branch teamai/push/member/20261026-143335
    exit 1
    # 7. split repo (git mode): nothing to push, then only teamai.yaml changed
    $ teamai push --all --carried nonsense
    ℹ No new or modified resources to push
    exit 0
    $ teamai push --all --carried nonsense
    ✔ Pushed branch teamai/push/member/20261026-143339
    exit 1
    

    After:

    # 1. nothing to push
    $ teamai push --all --carried nonsense
    ✖ --carried nonsense names no agent conversion this push stops for. Nothing was pushed. Pass the <path>@<blob> value a push stop printed, or push without --carried.
    exit 2
    # 2. only teamai.yaml changed
    $ teamai push --all --carried nonsense
    ✖ --carried nonsense names no agent conversion this push stops for. Nothing was pushed. Pass the <path>@<blob> value a push stop printed, or push without --carried.
    exit 2
    push branches: []
    # 4. carried conversion over the teammate's new YAML
    $ teamai push --all --role ops --carried .teamai/agents/ops/sample.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d --dry-run
    ✖ .teamai/agents/sample.yaml (pushed to .teamai/agents/ops/sample.yaml) changed both here and on origin/main since this checkout branched from it, so pushing would overwrite that change. Nothing was pushed. Merge origin/main (`git pull origin main`), resolve any conflict, then push again.
    exit 2
    $ teamai push --all --role ops --carried .teamai/agents/ops/sample.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d
    ✖ .teamai/agents/sample.yaml (pushed to .teamai/agents/ops/sample.yaml) changed both here and on origin/main since this checkout branched from it, so pushing would overwrite that change. Nothing was pushed. Merge origin/main (`git pull origin main`), resolve any conflict, then push again.
    exit 2
    push branches: []
    # 5. --skill sends an unrelated skill, with the conversion's value
    $ teamai push --all --skill .teamai/skills/independent --shared --carried .teamai/agents/ops/sample.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d
    ✖ --carried .teamai/agents/ops/sample.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d names no agent conversion this push stops for. Nothing was pushed. Pass the <path>@<blob> value a push stop printed, or push without --carried.
    exit 2
    push branches: []
    # 6. member pulls, folds the team YAML into its conversion, same value
    $ teamai push --all --role ops --carried .teamai/agents/ops/sample.md@8274783054d18fdb26fa7bd732c0a4a0e4373c3d
    ✔ Pushed branch teamai/push/member/20261026-143355
    exit 1
    $ git diff --name-status main teamai/push/member/20261026-143355
    D	.teamai/agents/ops/sample.md
    M	.teamai/agents/ops/sample.yaml
    $ git show teamai/push/member/20261026-143355:.teamai/agents/ops/sample.yaml
    name: sample
    description: A sample agent
    instructions: |
      Member replacement instructions.
      Teammate safety instructions.
      Team YAML instructions.
    # 7. split repo (git mode): nothing to push, then only teamai.yaml changed
    $ teamai push --all --carried nonsense
    ✖ --carried nonsense names no agent conversion this push stops for. Nothing was pushed. Pass the <path>@<blob> value a push stop printed, or push without --carried.
    exit 2
    $ teamai push --all --carried nonsense
    ✖ --carried nonsense names no agent conversion this push stops for. Nothing was pushed. Pass the <path>@<blob> value a push stop printed, or push without --carried.
    exit 2
    knowledge push branches: []
    

Local host: macOS 27.0, Node 24.21.0, Git 2.56.0. Native Windows, live vendor applications and other provider and agent combinations were not run locally and are left to CI.

Deleted test: pushes an agent conversion that carries the upstream edits each stop named. It required a plain retry after a stop to push, which is the behavior removed here; the --carried case above replaces it. The expected refusal text in refuses agent conversion after an upstream edit now names the --carried command.

Refs #1221; this PR addresses only its stated independent defect.

@github-actions

Copy link
Copy Markdown
  • [P1 blocking] src/resources/agents.ts:254: The new guard suppresses root agents even when a valid team source now exists. If this machine’s placed ops/sample is deleted and the team subsequently adds agents/sample.yaml, retiredPlacedAgents.sample still matches while placedAgents.sample is absent. Editing the new root agent then skips it—and any tool copies via directStems—instead of publishing the edit. Check the current team source before treating the root copy as a retired agent.

The PR description documents sufficient testing, including a representative real built-CLI E2E run. I only read the scoped diff; I did not run, build, or install anything.

@SaulMoro
SaulMoro self-requested a review October 23, 2026 14:46

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

@nateEc Thanks. Both agent cases from #1326 are fixed, but the new guard also hides a legitimate edit.

We built this head, its merge-base 83f6d1db and main 54622c3a. On main, both #1326 agent cases still reproduce. On this head, merging your own conversion no longer stops with exit 2, and the deleted agent is not pushed back. tsc and lint pass, the unit files pass, and self-mode-push-behind.test.ts passes 10/10, with 2 cases red on base.

  • [P1 blocking] src/resources/agents.ts:254 skips a root agent whenever retiredPlacedAgents has its name, without checking the team tree. Run with the built CLI: the team deletes the placed ops/sample, then re-adds agents/sample.yaml at the root. The member edits that root copy and runs teamai push --all:
    ⚠ [agents] sample was removed from the team; its root copy is not pushed as a new agent.
    ℹ No new or modified resources to push
    
    It exits 0 and pushes nothing, so the edit is silently lost. The record is never cleared, so this lasts as long as state.json keeps it. Checking that the team has no current source for the name before treating the root copy as retired, and dropping the record once the team has one, would fix it. A case in self-mode-push-behind.test.ts for the re-add would pin it.
  • [P2 non-blocking] Records written before this build still produce the old stop, with a message that is true but doesn't explain why.
  • [P2 non-blocking] The new code adds a ! in src/utils/pending-push.ts and an as in src/push.ts. A narrowing check would avoid both.
  • [P3 nit] troubleshooting.md conflicts with main at the end of the file, and the sharing.md paragraph is long.

#1333 changes the same push function for the skill case without a textual conflict. We didn't run the two together.

CI review: it raised one [P1 blocking] at agents.ts:254, the same as ours. We agree and reproduced it above. We did not verify its point about tool copies via directStems. We agree the body's testing record is a real built-CLI run.

@SaulMoro

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

@nateEc the troubleshooting.md conflict I mentioned is still there on current main, so a rebase is needed. The blocking finding is also still open: src/resources/agents.ts:254 skips a root agent whenever retiredPlacedAgents has its name, so a team that deletes the placed ops/sample and later re-adds agents/sample.yaml at the root never gets it delivered.

@nateEc
nateEc force-pushed the fix/1326-agent-format-history branch from 8bc3592 to 3044593 Compare October 24, 2026 17:28
@nateEc

nateEc commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review follow-up at 304459304ac1cea00a19f8cdbb19d64e02930b8a on current main.

  • Clear retired placed-agent history when the current team tree has re-added a shared-root source of that name. Deletion protection remains in place when no replacement exists.
  • The new record regression failed before the fix; placement-record tests now pass 27/27. Built-CLI self-mode-push-behind.test.ts: 11 passed, including the new re-add/edit scenario, both format-conversion cases and existing stale-source refusals.
  • The re-add scenario updates the checkout before the member edit; it does not bypass the existing both-sides-changed guard.
  • Build, type checking and lint passed.

The PR description contains the updated verification record. Ready for another review.

@github-actions

Copy link
Copy Markdown

No new findings in the scoped diff.

  • Resolved: The earlier root-agent suppression finding is fixed: reconciliation clears retired placement history when a shared-root source exists, with regression coverage for re-add/edit.
  • Testing: The PR description documents sufficient testing, including representative built-CLI E2E runs. No full provider × agent matrix is required.

I only read the scoped diff; I did not run, build, or install anything.

@nateEc
nateEc force-pushed the fix/1326-agent-format-history branch from 3044593 to 4f1d8ff Compare October 24, 2026 18:07
@nateEc

nateEc commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review follow-up at 4f1d8ff3962ae72f391d736e5314c3f4ca046f48 on current main.

  • Clear retired placed-agent history when the current team tree has re-added a shared-root source of that name. Deletion protection remains in place when no replacement exists.
  • The new record regression failed before the fix; placement-record tests now pass 27/27. Built-CLI self-mode-push-behind.test.ts: 11 passed, including the new re-add/edit scenario, both format-conversion cases and existing stale-source refusals.
  • The re-add scenario updates the checkout before the member edit; it does not bypass the existing both-sides-changed guard.
  • Build, type checking and lint passed.
  • Rebased again onto main a26f74d after fix(hooks): launch OpenCode through the installed Node entry #1336 merged; retained both troubleshooting sections. Rebase verification: 27 focused unit tests and 11 built-CLI E2E cases, build, types and lint passed.

The PR description contains the updated verification record. Ready for another review.

@github-actions

Copy link
Copy Markdown

No new findings in the scoped diff.

  • Resolved: The earlier root-agent suppression finding is fixed: reconciliation clears retired placement history when a shared-root source exists, with regression coverage for re-add/edit.
  • Testing: The PR description documents sufficient testing, including 11 representative built-CLI E2E cases. A full provider × agent matrix is not required.

I read only the trusted base review criteria and scoped diff. I did not run, build, or install anything from the PR.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

@nateEc Thanks, approving at 4f1d8ff. The blocking finding is fixed: re-adding an agent at the shared root now clears its retired record, and the re-add e2e fails on the commit before the fix. Both agent-format cases from #1326 are fixed. On the merge-base with this PR's tests, the false stop exits 2 and the deleted agent gets a pushed branch. Here self-mode-push-behind passes 11/11, also with a symlinked TMPDIR, and the focused unit files pass. Build, tsc and lint pass.

It conflicts with main again in skill-data/core/references/troubleshooting.md. Keeping both sections resolves it, and I'll merge it once it's rebased and green.

Each note below was reproduced with the built CLI on this head and on the merge-base:

  • [P2 non-blocking] The retired record is cleared only when the team re-adds the agent at the shared root. If the team brings it back at agents/ops/sample.md, for example by reverting the deletion, every later push, --role ops included, prints "sample was removed from the team" and pushes nothing, with exit 0. The base gets this flow wrong in another way (it publishes the edit as a new shared-root agent). A warning that names the retired path and the next step would at least make it visible.
  • [P2 non-blocking] The protection against a leftover tool copy holds only while the member's root copy exists. teamai pull delivers that root copy into .claude/agents/. If the member deletes the root copy, which the new warning suggests, the next push publishes the agent as a new agents/sample.yaml. This already happens on main, but the body says the case is covered. The e2e writes the tool copy by hand and keeps the root copy, so it does not reach this path.
  • [P2 non-blocking] A member who is fully up to date still deletes a teammate's merged edit when converting .md to .yaml. The new docs sentence "a later team edit still stops the push" holds only while the member is behind that edit. This also happens on main. The blob this PR now records would be enough to catch it.
  • [P3 nit] The stop message for pre-build records is unexplained (src/push.ts:1177). There is a non-null assertion at src/utils/pending-push.ts:497 and an as cast at src/push.ts:1109. The new docs omit the re-add case.

The CI review reports no new findings and calls the earlier one resolved. We agree that nothing blocks, but it missed the namespaced re-add above and accepted the tool-copy claim. All CI jobs pass.

- Record each landed agent placement with its proven path and Git blob, and prune that metadata with the placement lifecycle.
- Allow format conversion behind the placement merge only when the retiring file still matches that delivered blob; keep teammate-edit and legacy-record guards.
- Remember upstream-deleted agents even before the first observed merge, and suppress publication from both canonical conversions and residual tool copies.
- Verify 87 placement/agent tests, ten built-CLI push scenarios, type checking and lint; document the behavior in both guide languages and troubleshooting.
- 团队树中重新出现同名共享根 agent 时清除旧命名空间的退役记录,允许成员提交该新来源的编辑。
- 保留团队删除时的防复活保护与并发修改拒绝,避免把真正的重新加入误判为残留副本。
- 新单测在修复前失败;27 个记录用例和 11 个真实 CLI 用例通过,包含删除、格式转换及重新加入后的编辑。
- 即使 checkout 已同步,也比较交付时的源 blob,阻止转换删除队友修改。
- 退役的工具副本不再成为新 agent;命名空间重建时明确提示原始路径和编辑步骤。
- 移除不必要的类型断言,补充中英文恢复指引及旧记录拒绝原因。
- 119 项定向单测和 19 项真实 CLI 场景通过,类型、lint 与构建通过。
@nateEc
nateEc force-pushed the fix/1326-agent-format-history branch from 4f1d8ff to 22cd674 Compare October 26, 2026 04:38
@github-actions

Copy link
Copy Markdown
  • [P1 blocking] src/push.ts:1132: Conversion remains blocked even after following the recovery instructions. If placement recorded blob A, a teammate changes the original to B, and the author updates the checkout and includes B’s changes in the converted YAML, retiredTip !== deliveredBlob still rejects every push. Reconciliation preserves A, and this guard never checks the reconciled conversion. Allow a conversion that incorporates the current source; otherwise “pull, carry that change … then push again” cannot recover.

  • Resolved: The earlier root-agent suppression finding is fixed: reconciliation clears retired history when a shared-root source exists, with re-add/edit regression coverage.

  • Testing: The description documents sufficient representative built-CLI E2E verification. No full provider × agent matrix is required.

I reviewed the trusted base criteria and exact requested diff ending at 22cd6749, not the different head named in the body. I did not run, build, or install anything from the PR.

@nateEc

nateEc commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Updated and rebased onto main fc8a229e. Protect format conversions against teammate changes even when the checkout is fully synchronized, by comparing the recorded delivered blob with the current default-branch blob. Reject edited leftover tool copies as new shared-root agents. A namespaced source recreated by the team remains a distinct source: the warning names its exact path and directs the member to edit that canonical source after updating the checkout, while keeping retired flattened copies as backups. Older records explain their missing delivered-blob evidence. Remove unnecessary narrowing assertions.

Verification: 119 focused unit tests passed; types, lint and build passed. Post-build real-CLI self-mode-push-behind: 19 passed. Native Windows and live vendor/provider combinations remain CI coverage. The PR body now describes this branch's current verification rather than an older combined snapshot.

Updated head: 22cd6749.

@SaulMoro
SaulMoro self-requested a review October 26, 2026 07:40

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

@nateEc Re-checked at 22cd674. The earlier items are fixed, each with an e2e or unit case: re-adding a root agent, the namespaced re-add, the leftover tool copy, and the stale message and cast. But the new guard blocks the recovery it tells the user to do, so our earlier approval (on 4f1d8ff) cannot carry over.

  • [P1 blocking] A conversion after a teammate's edit is refused even when the member has carried the edit in (src/push.ts:1131-1132). Reproduced with the built CLI:

    1. The member's agent is placed, recording blob A.
    2. A teammate changes the original on origin/main to B.
    3. The member pulls, carries B's line into sample.yaml, and runs push --all --role ops.

    This head exits 2 with ... would delete .teamai/agents/ops/sample.md, which changed on origin/main since this machine delivered it. Nothing was pushed. Run 'git pull origin main', carry that change into .teamai/agents/sample.yaml, then push again. It does the same on every retry, so there is no way out. main pushes the same conversion. retiredTip !== deliveredBlob stays true because reconciliation keeps A, and the guard never looks at whether the converted file now holds the current source. Please let a conversion through when it already carries the current tip, or update the recorded blob once the member has pulled, and add an e2e case for the carried conversion. The troubleshooting text promises exactly this recovery.

  • [P2 non-blocking] Older records with no delivered blob still delete a teammate's merged edit on a synced checkout. That also happens on main, but the new docs say older records "stay conservative". Please either backfill the blob or reword the docs.

Build, tsc, lint, the PR's unit files (119 tests) and its e2e file (19 tests) pass, and a batch of 30 push and agent e2e files passes except one that fails on main too.

The CI review's [P1 blocking] at this head is the same finding, and we agree with it. The other CI jobs pass. The open-source scan check fails at this head, where it passed at 4f1d8ff; its report is on an internal host, so we could not read the cause.

# Conflicts:
#	skill-data/core/references/troubleshooting.md
…am edit

The member's root copy is never refreshed from the team file, so a push
cannot tell whether a conversion carries a teammate's edit. Each stop now
records the version it named; the next push takes the conversion as
carrying it, and a later team edit stops it again. A dry run records
nothing. Reword the docs for older placement records, which catch a team
edit only while the checkout is behind it.
@github-actions

Copy link
Copy Markdown

No new findings in the scoped diff ending at a0af3af.

  • Resolved: Shared-root re-additions clear retired placement history, allowing subsequent edits to publish.
  • Resolved: Conversion stops now record the named upstream blob, allowing a reconciled retry while stopping again for later upstream edits.
  • Testing: The PR description documents sufficient testing, including 19 representative built-CLI E2E cases. No full provider × agent matrix is required.

I read only the trusted base review criteria and scoped diff. I did not run, build, or install anything from the PR.

# Conflicts:
#	skill-data/core/references/troubleshooting.md
A stop no longer records the team version it named, so an unchanged
retry stops again instead of deleting the teammate's edit. The stop
prints `teamai push --carried <path>@<blob>`; with it, the push deletes
the original only while the default branch still holds that blob, and
a later team edit stops it again. Nothing is written to state, so a
dry run or another checkout of the same project gains nothing from it.
A value that names no stopped conversion is rejected.
# Conflicts:
#	skill-data/core/references/troubleshooting.md
@github-actions

Copy link
Copy Markdown

No new findings in the scoped diff ending at d275d972.

  • Resolved: Shared-root re-additions clear retired placement history, allowing subsequent edits to publish.
  • Resolved: Conversion recovery now uses explicit --carried <path>@<blob> acknowledgment; a later upstream version stops the push again.
  • Testing: The description documents sufficient representative built-CLI E2E verification. Its real-CLI record names an older commit, which the trusted criteria treat as a note, not a blocker. Additional provider/agent coverage is explicitly deferred to CI.

I read only the trusted base criteria and scoped diff. I did not run, build, or install anything from the PR.

@github-actions

Copy link
Copy Markdown

No new findings in the scoped diff ending at cfb7fe23.

  • Resolved: Shared-root re-additions clear retired placement history, allowing subsequent edits to publish.
  • Resolved: Conversion recovery requires explicit --carried <path>@<blob> acknowledgment; unchanged retries remain blocked, and later upstream edits require a new value.
  • Testing: The description documents sufficient testing, including representative built-CLI E2E verification. Additional provider/agent coverage is explicitly deferred to CI.

I read only the trusted base review criteria and scoped diff. I did not run, build, or install anything from the PR.

@github-actions

Copy link
Copy Markdown

No new findings in the scoped diff ending at 762a11cd.

  • Resolved: Shared-root re-additions clear retired placement history, allowing subsequent edits to publish.
  • Resolved: Conversion recovery uses explicit --carried <path>@<blob> acknowledgment; plain retries remain blocked, and later upstream edits require a new value.
  • Testing: The description documents sufficient representative built-CLI E2E verification. Additional provider/agent coverage is explicitly deferred to CI.

I read only the trusted base review criteria and scoped diff. I did not run, build, or install anything from the PR.

…ts first merged edit

A placement record written before placedAgentSources existed has no
delivered blob, so its edits were never marked and the overwrite stop
never applied to it. An edit reached through such a record is now marked
as a placement, and reconcile records its blob once it lands. Nothing new
stops on that push and nothing is written before the merge.
@github-actions

Copy link
Copy Markdown

No new findings in the scoped diff ending at a2c73231.

  • Resolved: Shared-root re-additions clear retired placement history, allowing subsequent edits to publish.
  • Resolved: Conversion recovery requires explicit --carried <path>@<blob> acknowledgment; plain retries remain blocked, and later upstream edits require a new value.
  • Testing: The description documents sufficient representative built-CLI E2E verification. Additional provider/agent coverage is explicitly deferred to CI.

I read only the trusted base review criteria and scoped diff. I did not run, build, or install anything from the PR.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved at a2c7323. The conversion and overwrite stops, the stateless --carried acknowledgment and the delivered-blob record (including records from older releases) check out on the built CLI. CI and the review bot are clean.

@SaulMoro
SaulMoro merged commit 8116777 into Tencent:main Oct 26, 2026
18 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
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.

3 participants