Skip to content

fix(scripts): let first-agent reruns accept their own older revision - #3954

Merged
freeqaz merged 1 commit into
mainfrom
fix-2770
Oct 28, 2026
Merged

freeqaz merged 1 commit into
mainfrom
fix-2770

Conversation

@freeqaz

@freeqaz freeqaz commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Problem

scripts/first-agent.mjs refuses to reuse an Agent when the saved or active revision differs from what this helper would deploy. Deployment admission fills the Gateway security defaults that the Configuration leaves unset, and the helper accepted its own identified prior revision only when it carried none or all of those defaults. Each default landed separately (tools.exec.applyPatch.workspaceOnly in #3903, agents.defaults.sandbox.mode in #3951). So a revision deployed by an OCC from between those changes has only some of the defaults. A rerun against that Agent then failed with "This Agent revision was changed outside this helper. Use a new Agent name". The only way to recover was a new Agent name.

Change

  • firstAgentRevisionValuesMatch: for the helper's own identified prior revision (revisionId === priorRevisionId) only, apply admitGatewaySecurityDefaults to both the saved values and the configured values before comparing. A default that is merely absent (admission would fill it) now matches. An explicit, different value is still drift, because the fill keeps values that are already set.
  • The current-deploy path and any other revision stay strict: they are compared against the fully admitted snapshot.
  • No per-version special cases. Any default added in the future gets the same treatment automatically.

Verification

  • tests/integration/first-agent-startup.test.mjs extends the existing identified-revision test with a table of prior revisions missing both defaults, only the sandbox mode, and only apply_patch. Each one matches as the identified prior revision and fails as another revision or a new deployment. Two more cases: an explicit workspaceOnly: false and an explicit sandbox mode other than off both still fail on the prior revision.
  • Against the unfixed script, the new cases fail.
  • The whole test file passed 3 of 3 runs on a remote test VM. Prettier and ESLint pass on the touched files.

Risks

Low. This is a local development helper. The relaxation applies only to the revision the helper itself recorded, and only for keys that admission fills when they are unset. Explicit looser values and all other drift checks are unchanged.

The helper accepted its own prior revision only when it carried none or all
of the Gateway security defaults admission fills. Each new default made
revisions deployed in between look changed outside the helper. For the
identified prior revision only, fill the defaults on both sides before
comparing: a missing default matches, an explicit different value is still
drift. New deployments stay strict.
@freeqaz
freeqaz requested a review from a team as a code owner October 28, 2026 14:14
@clawsweeper

clawsweeper Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

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.

1 participant