Repository navigation
feat(gemini): deploy agents to .gemini/agents with validated frontmatter - #4593
Mohit Mishra (mohitmishra786) wants to merge 20 commits into
Conversation
|
Thank you Mohit Mishra (@mohitmishra786), this matches the approach agreed on #2990, including the fail-closed handling of unsupported |
There was a problem hiding this comment.
🟡 Changes recommended
The new test modules lack required taxonomy markers and fail the quality gate, while agent preflight accepts NaN temperatures and incorrectly rejects BOM-prefixed frontmatter.
4 open issues
What changed in this PR
Adds Gemini CLI agent deployment to APM's existing target integration system, covering project and global installs. This implements the Gemini portion of #2990; Antigravity remains separate.
Changes:
- Adds frontmatter validation and rendering before agent adoption or deployment, with warnings for unsupported agents.
- Prevents local bundles from bypassing Gemini agent validation.
- Adds rendering, lifecycle, and conformance coverage, and updates target documentation.
| File | Description |
|---|---|
tests/unit/integration/test_gemini_agents.py |
Tests validation, rendering, deployment, and cleanup. |
tests/unit/integration/test_data_driven_dispatch.py |
Adds the Gemini agents dispatch bucket. |
tests/unit/integration/test_agent_integrator.py |
Excludes Gemini from verbatim-copy expectations. |
tests/unit/install/test_install_local_bundle.py |
Tests Gemini bundle-agent skipping. |
tests/unit/core/test_target_catalog.py |
Records the Gemini agent mapping. |
tests/spec_conformance/test_manifest_reqs.py |
Adds Gemini tool-validation conformance coverage. |
tests/integration/test_gemini_agent_lifecycle.py |
Exercises project and global agent lifecycles. |
tests/integration/test_architecture_confirmed_bypass_mutations.py |
Tests detection of bundle-validation bypasses. |
src/apm_cli/integration/targets.py |
Maps Gemini agents to validated Markdown. |
src/apm_cli/integration/agent_integrator.py |
Implements Gemini validation and rendering. |
src/apm_cli/install/local_bundle_paths.py |
Blocks unvalidated bundle-agent copies. |
src/apm_cli/core/target_detection.py |
Includes agents in the Gemini target description. |
scripts/architecture_linter/checks/marketplace_package_and_registration.py |
Extends the bundle-layout guard. |
packages/apm-guide/.apm/skills/apm-usage/package-authoring.md |
Documents Gemini agent authoring constraints. |
packages/apm-guide/.apm/skills/apm-usage/commands.md |
Documents Gemini bundle-agent skipping. |
docs/src/content/docs/reference/targets-matrix.md |
Describes agent support and Gemini acknowledgement requirements. |
docs/src/content/docs/reference/manifest-schema.md |
Lists the Gemini agent destination. |
docs/src/content/docs/reference/cli/audit.md |
Adds Gemini agents to documented audit coverage. |
CONFORMANCE.md |
Updates the requirement coverage count. |
CONFORMANCE.json |
Registers the new conformance test. |
CHANGELOG.md |
Announces Gemini agent deployment. |
Review effort: Balanced
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 1 | 2 | 0 | Gemini preflight is the single render+validate owner and runs before adopt and mkdir. Fix the fail-open drop of restricting keys and the name vs file-stem split. |
| Test Coverage Expert | 0 | 3 | 0 | Real-CLI Gemini lifecycle is solid and plausibly fails-before; add .gemini write-set snapshot, a failed-command integrity step, and PR-time smoke selection. |
| Supply Chain Security Expert | 0 | 3 | 0 | Tool, model and trust handling fail closed, but the renderer silently drops keys that restrict access, such as hooks and disable-model-invocation. Refuse them or allowlist keys. |
| Doc Writer | 0 | 3 | 0 | Required doc surfaces updated, CHANGELOG and ASCII clean, folder-trust wording kept. Fix the incomplete rejection list, trim the matrix paragraph, add a guide gotcha. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 5 follow-ups
- [Python Architect] (blocking-severity) Replace the silent drop with allowlist-or-diagnose. Skip the agent with a
Fix:hint when it has a restriction-bearing key:hooks,readonly,permission,disable-model-invocation: true, orinfer: false. Move the Codex dropped-field warning into one shared helper and call it from the Gemini preflight, so every other dropped key is named in a warning. Add unit tests, for example: an agent withhooksand notoolsis not written to.gemini/agents. (Merges the Supply Chain Security findings onhooksand ondisable-model-invocation/infer.) -- The [FEATURE] Be able to configure sub-agents for gemini and antigravity #2990 scope record requires that unsupported fields never silently broaden access. Today a dropped restriction key plus an omittedtoolslist gives the agent every Gemini session tool. - [Test Coverage Expert] Add a lifecycle scenario that seeds only
.gemini/settings.jsonand installs a package whose only agent is invalid; assert the.geminitree is byte-identical and noagentsdir exists. In the valid steps, assert that the only change under.geminiis the deployed agent file, and thattrustedFolders.jsonand the acknowledgements store are absent or unchanged in both project and-gscope. (Merges the Supply Chain Security trust/ack snapshot finding.) -- Render-before-mkdir and never touching trust or acknowledgement state are covered only by unit tests today; both lifecycle scenarios pre-create.gemini/agents, so the CLI tier never exercises either promise. - [Test Coverage Expert] Add a failed-command step to the project lifecycle test: point the ref at a SHA that does not exist, run install, assert a non-zero exit, and assert the deployed agent bytes and lockfile rows are unchanged. -- Failure-state integrity is a [FEATURE] Be able to configure sub-agents for gemini and antigravity #2990 Done-when item, and every current lifecycle step asserts success.
- [Python Architect] Require the frontmatter
name, when present, to equal the file stem; otherwise skip with a warning naming the expected file name. Add a unit test. -- Today the file name and agent name can differ, so a package agent can shadow a user agent by name while collision and adoption checks, which compare file paths, see no conflict. The maintainer guidance was<name>.mdonly. - [Doc Writer] Write one complete list of refused keys and accepted tool forms (including
disallowed-tools,agent_card_url,agent_card_json,auth,discovered_tool_<name>and the leading-underscore rule) intargets-matrix.mdandpackage-authoring.md, updated for the restriction-key change. Split the long Gemini Agents bullet into 3-4 sub-bullets and move upstream source-file links into the integrator comment, keeping the folder-trust wording. Add the "Gemini skips the whole agent" gotcha toproducer/write-primitives.md. -- The reference docs must match the code, and producers never see the whole-agent skip on the page they read.
Recommendation
The approach matches #2990 and should land once a small set of fixes is added to this PR. The one item to finish first is the allowlist-or-diagnose change for restriction-bearing frontmatter keys, with its unit tests, because it closes an explicit scope-record clause. In the same PR, fold in the .gemini write-set and failed-install lifecycle steps, the name-equals-stem check and the docs list. Fork CI at 7fcf617 already shows two PR-caused failures to fix here: (a) Architecture Ratchet Contracts / Test Architecture Ratchets (taxonomy tm006): tests/unit/integration/test_gemini_agents.py needs a module-level pytestmark with one behavioral marker (pytest.mark.unit) and a pytest.mark.promise(...) id from tests/quality/promise-catalog.json, and tests/integration/test_gemini_agent_lifecycle.py needs a pytest.mark.promise(...) too (the ratchet suggests P-OWN-distributed-agents-output-preparation and P-OWN-agent-plugin-package-projection); (b) the assertion-quality baseline (AQ003, observed 19 vs allowed 18) flags the new req-tg-009 test in tests/spec_conformance/test_manifest_reqs.py; make it assert on the warning output or the files left on disk, not only on return values. uv run --extra dev python -m tests.quality.taxonomy --changed reproduces (a) locally. Confirm the remaining Lifecycle Smoke shards finish green before landing. The renderer-shape cleanup (one return shape, a format_id -> renderer mapping, and a static guard against mkdir inside integrate_agents_for_target) and the lifecycle_smoke marker on the project-scope test can land here or open the Antigravity PR, but should be settled before that next branch is added.
Full per-persona findings
Python Architect
- [blocking] Unknown frontmatter keys are dropped silently, and the deny list is fail-open, so keys that restrict access (Cursor
readonly, OpenCodepermission) disappear without any warning atsrc/apm_cli/integration/agent_integrator.py:1228
_preflight_render_gemini_agentkeeps only name, description, tools, model and the optional fields, and drops every other key with no diagnostic._GEMINI_AGENT_REJECTED_FIELDSis a closed list of nine keys. Cursorreadonly: trueand OpenCodepermission: {edit: deny, bash: deny}are dropped,toolsstays omitted, and Gemini gives the agent every session tool. A closed deny list fails open whenever a harness adds a restriction key. The Codex path in the same file already warns about dropped keys (_MAX_DROPPED_FIELDS_SHOWN,_display_dropped_field_key) but inline.
Suggested: Extract the Codex dropped-fields diagnostic into one helper and call it from the Gemini preflight; addreadonlyandpermissionto the rejected set, or skip the agent whentoolsis omitted and any key outside a known-safe set is present. - [recommended] Deployed file name comes from the file stem but the Gemini agent name can come from frontmatter, so file-based collision checks miss agent-name collisions at
src/apm_cli/integration/agent_integrator.py:1225
A package agentcode-review.mdwithname: reviewercan shadow a user's.gemini/agents/reviewer.md; collision and adopt checks are keyed on file paths. Two values decide one identity.
Suggested: Require the frontmatter name, when present, to equal the stem. Add a unit test. - [recommended] Per-format if/elif renderers return different tuple shapes and render-before-mkdir order rests only on unit tests; settle before Antigravity adds the next branch at
src/apm_cli/integration/agent_integrator.py:381
Kiro returns(rendered, ok: bool), Gemini(rendered | None, links: int). The else branch still mkdirs eagerly though_deploy_rendered_agentowns mkdir. Theinstall-deployment-agent-render-then-adoptguard covers adoption and writes for the Gemini branch, but not render-before-mkdir.
Suggested: One renderer shape, aformat_id-> renderer mapping, drop the eager-mkdir else branch, and extendcheck_agent_render_then_adoptto refusemkdir()insideintegrate_agents_for_target.
Test Coverage Expert
- [recommended] No real-CLI test snapshots the files written under
.gemini: render-before-mkdir and no trust/acknowledgement writes are untested at that tier attests/integration/test_gemini_agent_lifecycle.py
Both scenarios pre-create.gemini/agentsin_seed_gemini_dir; only the unit testtest_gemini_agent_rejected_with_warning_and_nothing_writtenasserts render-before-mkdir.
Suggested: Seed only.gemini/settings.jsonwith an all-invalid package; assert a byte snapshot of.geminiis unchanged. Use a tree snapshot diff in the valid steps.
Proof (missing at):tests/integration/test_gemini_agent_lifecycle.py::test_gemini_agent_all_invalid_leaves_gemini_tree_untouched-- proves: Installing a package whose Gemini agents are all invalid leaves my .gemini directory byte-identical. [secure-by-default,multi-harness-support] - [recommended] Failure-state integrity has no regression trap: every lifecycle step asserts
returncode == 0attests/integration/test_gemini_agent_lifecycle.py
invalid-updateis a successful install that skips an agent; it proves stale cleanup, not integrity after a failed command.
Suggested: Point the ref at a non-existent SHA, assert non-zero exit and unchanged deployed bytes and ledger rows.
Proof (missing at):tests/integration/test_gemini_agent_lifecycle.py::test_gemini_agent_project_lifecycle (failed-update step)-- proves: If an install fails partway, the Gemini agents and lockfile records I already had stay exactly as they were. [portability-by-manifest,secure-by-default] - [recommended] The Gemini lifecycle test is not marked
lifecycle_smoke, so no PR-time CI job runs it; it first runs in the merge_group hermetic integration shards attests/integration/test_gemini_agent_lifecycle.py:31
Precedent is mixed:test_kiro_agent_lifecycle.pyhas no smoke marker;test_kiro_prompt_lifecycle.pyandtest_opencode_v2_lifecycle.pydo. The fail-before claim is credible from the exact frontmatter and ledger-row assertions.
Suggested: Addpytest.mark.lifecycle_smoketo the project-scope test after checking its duration.
Proof (unknown):tests/integration/test_gemini_agent_lifecycle.py::test_gemini_agent_project_lifecycle-- proves: The real apm binary keeps the deployed Gemini agent and lockfile in agreement across the lifecycle. [multi-harness-support,portability-by-manifest]
Supply Chain Security Expert
- [recommended] Claude subagent
hooks(for example PreToolUse deny guards) are silently dropped, so the deployed Gemini agent loses that guard atsrc/apm_cli/integration/agent_integrator.py:159
A Claude agent that omitstoolsand relies on a hooks deny guard deploys with full session tools and no guard. Agents with Claude or Copilot tool names are already caught byis_gemini_agent_tool.
Suggested: Addhooksto the rejected set, or switch to an allowlist that accepts known cosmetic keys and rejects any other, or at least warn per dropped key as Codex does.
Proof (missing at):tests/unit/integration/test_gemini_agents.py-- proves: An agent whose source restricts tool use via hooks is never deployed to Gemini without that restriction. [secure-by-default,multi-harness-support] - [recommended]
disable-model-invocation: trueand Copilotinfer: falseare silently dropped, so Gemini can auto-delegate to an agent its author marked model-uninvocable atsrc/apm_cli/integration/agent_integrator.py:1218
_warn_user_invocable_droppedcovers onlyuser-invocable/visibility.
Suggested: Skip with aFix:hint, or at minimum warn, when either is set. - [recommended] Lifecycle test does not check that Gemini trust and acknowledgement state is left untouched at
tests/integration/test_gemini_agent_lifecycle.py
No code path writes them today; a cheap absence or equality check traps a future pre-acknowledgement regression.
Suggested: Assert~/.gemini/trustedFolders.jsonand the acknowledgements store are absent or byte-identical across install, update and uninstall in both scopes.
Proof (missing at):tests/integration/test_gemini_agent_lifecycle.py-- proves: Installing or updating Gemini agents never pre-trusts a folder or pre-acknowledges an agent. [secure-by-default]
Doc Writer
- [recommended] The documented rejected-key list omits keys the code rejects (
disallowed-tools,agent_card_url,agent_card_json,auth) and thediscovered_tool_<name>and leading-underscore rules atdocs/src/content/docs/reference/targets-matrix.md:240
The reference page should match_GEMINI_AGENT_REJECTED_FIELDS.
Suggested: Use one complete list intargets-matrix.mdandpackage-authoring.md. - [recommended] Trim the targets-matrix Gemini Agents bullet (about 30 lines, 7 inline links) at
docs/src/content/docs/reference/targets-matrix.md:227
Length comes from upstream source-file links that are maintainer evidence, and one prose wall.
Suggested: Split into 3-4 sub-bullets; keep the subagents, tools and configuration links and the folder-trust text; moveagentLoader.ts,registry.ts,AppContainer.tsxlinks to the integrator comment. - [recommended] The producer guide Agents gotcha does not mention that Gemini skips the whole agent rather than dropping a field at
docs/src/content/docs/producer/write-primitives.md:82
A portable Claude-style agent (tools: [Read],model: sonnet) is not deployed to Gemini at all.
Suggested: Replace the Codex sentence with one that also names the Gemini whole-agent skip and links the targets matrix.
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.
microsoft#4593) Gemini's frontmatter regex allows a leading BOM and its z.number() schema rejects NaN, so the preflight now parses through yaml_io.loads_frontmatter (which strips the BOM, as the prompt and instruction integrators do) and rejects a NaN temperature. Infinity stays accepted, as in Gemini. The new test modules carry taxonomy markers and assert on-disk state; the two pure-logic tests move to test_gemini_agent_rules.py (unit).
00b60fa to
7e320ea
Compare
microsoft#4593) Gemini's frontmatter regex allows a leading BOM and its z.number() schema rejects NaN, so the preflight now parses through yaml_io.loads_frontmatter (which strips the BOM, as the prompt and instruction integrators do) and rejects a NaN temperature. Infinity stays accepted, as in Gemini. The new test modules carry taxonomy markers and assert on-disk state; the two pure-logic tests move to test_gemini_agent_rules.py (unit).
…icrosoft#4593) Dropping a key that restricts an agent, with no tools list, would give it every Gemini session tool. An agent is now skipped with a warning when it declares hooks, isolation, permissions or permission, or sets readonly: true, disable-model-invocation: true, infer: false or disabled/disable: true (Claude, Copilot, Cursor and OpenCode docs linked in the code). Every other dropped key is named in a warning through a helper extracted from the Codex renderer, whose messages are unchanged.
Gemini identifies an agent by its 'name' while APM's collision and adoption checks compare file paths, so code-review.md with name: reviewer could shadow a user's reviewer.md unnoticed. Such an agent is now skipped with a warning naming the expected file.
…rosoft#4593) A package whose only agent is invalid leaves a .gemini tree holding only settings.json byte-identical, with no agents directory. In the project and -g installs the deployed agent is the only change under .gemini, so APM never writes trustedFolders.json or Gemini's acknowledgement store.
…microsoft#4593) The project lifecycle points the ref at a commit that does not exist, expects a non-zero exit, and checks that the deployed agent and the lockfile bytes are unchanged before restoring the valid ref.
…t#4593) The targets matrix and apm-usage skill now carry one complete list of the keys that skip an agent and the accepted tool forms, including the restriction keys, the name-equals-stem rule and the leading-underscore rule. The Gemini agents bullet is split into sub-bullets, upstream source links move to the integrator comment, and the producer guide notes that Gemini skips the whole agent rather than one field.
…icrosoft#4593) The project-scope Gemini lifecycle is hermetic (local git, no network) and takes about 4 s, so it now runs in the required PR-time job instead of only in the merge-group shards.
…icrosoft#4593) integrate_agents_for_target now calls a single _render_agent_for_target, which picks the renderer by format_id and always returns (rendered or None, links_resolved). The eager mkdir for copy and Codex targets is gone: _deploy_rendered_agent creates the parent only when it writes, so a package whose agents are all skipped leaves the target tree untouched. The render-then-adopt guard now refuses mkdir() in the agent loop (with a bypass mutation case), and the Codex link-resolution guard checks the new dispatch point. This settles the shape before Antigravity adds a renderer.
|
Thanks for the review. Every finding is addressed in this PR, one commit each; details below. Commits refer to the current head (rebased on CI failures listed under Recommendation (taxonomy tm006, AQ003 baseline) were fixed in 5cce5a9, before this panel ran on 7fcf617. Two differences from the panel's suggestion:
1. Restriction-bearing keys (Python Architect, blocking; Supply Chain Security) -- 93b6944 An agent is now skipped with a
Two corrections to the panel's list:
The Codex dropped-field warning is now a shared Tests: each key in the rejection table, with no 2.
3. Failed-command integrity (Test Coverage) -- 8696b82 The project lifecycle points the ref at 4. Name equals file stem (Python Architect) -- fce7d00 When 5. Docs (Doc Writer) -- 2e8bb2e
6. Lifecycle Smoke (Test Coverage) -- 908790c
7. Renderer shape (Python Architect) -- dcbd72d Done here rather than in the Antigravity PR:
Verification on the rebased head: ruff, the duplication check, auth-signal and architecture lint, and the complexity ratchet are clean. The Rebase on #3714: Rebase on #4282 (write seam): |
7e320ea to
70da59a
Compare
microsoft#4593) Gemini's frontmatter regex allows a leading BOM and its z.number() schema rejects NaN, so the preflight now parses through yaml_io.loads_frontmatter (which strips the BOM, as the prompt and instruction integrators do) and rejects a NaN temperature. Infinity stays accepted, as in Gemini. The new test modules carry taxonomy markers and assert on-disk state; the two pure-logic tests move to test_gemini_agent_rules.py (unit).
…icrosoft#4593) Dropping a key that restricts an agent, with no tools list, would give it every Gemini session tool. An agent is now skipped with a warning when it declares hooks, isolation, permissions or permission, or sets readonly: true, disable-model-invocation: true, infer: false or disabled/disable: true (Claude, Copilot, Cursor and OpenCode docs linked in the code). Every other dropped key is named in a warning through a helper extracted from the Codex renderer, whose messages are unchanged.
Gemini identifies an agent by its 'name' while APM's collision and adoption checks compare file paths, so code-review.md with name: reviewer could shadow a user's reviewer.md unnoticed. Such an agent is now skipped with a warning naming the expected file.
…rosoft#4593) A package whose only agent is invalid leaves a .gemini tree holding only settings.json byte-identical, with no agents directory. In the project and -g installs the deployed agent is the only change under .gemini, so APM never writes trustedFolders.json or Gemini's acknowledgement store.
…microsoft#4593) The project lifecycle points the ref at a commit that does not exist, expects a non-zero exit, and checks that the deployed agent and the lockfile bytes are unchanged before restoring the valid ref.
…t#4593) The targets matrix and apm-usage skill now carry one complete list of the keys that skip an agent and the accepted tool forms, including the restriction keys, the name-equals-stem rule and the leading-underscore rule. The Gemini agents bullet is split into sub-bullets, upstream source links move to the integrator comment, and the producer guide notes that Gemini skips the whole agent rather than one field.
…icrosoft#4593) The project-scope Gemini lifecycle is hermetic (local git, no network) and takes about 4 s, so it now runs in the required PR-time job instead of only in the merge-group shards.
…icrosoft#4593) integrate_agents_for_target now calls a single _render_agent_for_target, which picks the renderer by format_id and always returns (rendered or None, links_resolved). The eager mkdir for copy and Codex targets is gone: _deploy_rendered_agent creates the parent only when it writes, so a package whose agents are all skipped leaves the target tree untouched. The render-then-adopt guard now refuses mkdir() in the agent loop (with a bypass mutation case), and the Codex link-resolution guard checks the new dispatch point. This settles the shape before Antigravity adds a renderer.
…rosoft#4593) A package whose only agent is invalid leaves a .gemini tree holding only settings.json byte-identical, with no agents directory. In the project and -g installs the deployed agent is the only change under .gemini, so APM never writes trustedFolders.json or Gemini's acknowledgement store.
…microsoft#4593) The project lifecycle points the ref at a commit that does not exist, expects a non-zero exit, and checks that the deployed agent and the lockfile bytes are unchanged before restoring the valid ref.
…t#4593) The targets matrix and apm-usage skill now carry one complete list of the keys that skip an agent and the accepted tool forms, including the restriction keys, the name-equals-stem rule and the leading-underscore rule. The Gemini agents bullet is split into sub-bullets, upstream source links move to the integrator comment, and the producer guide notes that Gemini skips the whole agent rather than one field.
…icrosoft#4593) The project-scope Gemini lifecycle is hermetic (local git, no network) and takes about 4 s, so it now runs in the required PR-time job instead of only in the merge-group shards.
…icrosoft#4593) integrate_agents_for_target now calls a single _render_agent_for_target, which picks the renderer by format_id and always returns (rendered or None, links_resolved). The eager mkdir for copy and Codex targets is gone: _deploy_rendered_agent creates the parent only when it writes, so a package whose agents are all skipped leaves the target tree untouched. The render-then-adopt guard now refuses mkdir() in the agent loop (with a bypass mutation case), and the Codex link-resolution guard checks the new dispatch point. This settles the shape before Antigravity adds a renderer.
…ents (microsoft#4593) After microsoft#3714 local bundle install renders packed Markdown agents to Codex TOML, so the apm-usage sentence no longer says Codex agents are skipped; Gemini agents and Gemini commands still are.
|
Daniel Meppiel (@danielmeppiel) Rebased on The CI runs on this fork PR are still waiting for approval, so none have run since the last rebase. Could you approve them, and let me know if anything needs changing before this can merge? I |
…ter (microsoft#2990) Gemini CLI v0.70.0 loads local subagents from .gemini/agents/*.md and ~/.gemini/agents/*.md and rejects a file with any frontmatter key outside its schema, so a verbatim copy does not load. The gemini_agent renderer keeps only the schema keys, takes name from frontmatter or the file stem, and skips (with a warning) an agent Gemini would reject or that APM cannot carry without changing its access: foreign tool or model names, agent-scoped MCP servers, disallowedTools, permissionMode, kind: remote. It runs before any adopt check or write, like the Kiro preflight. Local bundle installs skip Gemini agents, as they do Codex agents, since they cannot run the renderer.
The Gemini rejection now names the approved tool set, as req-tg-009
requires, and a conformance test checks fail-closed before adopt with a
conformant sibling still deployed. CONFORMANCE.{md,json} regenerated.
microsoft#4593) Gemini's frontmatter regex allows a leading BOM and its z.number() schema rejects NaN, so the preflight now parses through yaml_io.loads_frontmatter (which strips the BOM, as the prompt and instruction integrators do) and rejects a NaN temperature. Infinity stays accepted, as in Gemini. The new test modules carry taxonomy markers and assert on-disk state; the two pure-logic tests move to test_gemini_agent_rules.py (unit).
…icrosoft#4593) Dropping a key that restricts an agent, with no tools list, would give it every Gemini session tool. An agent is now skipped with a warning when it declares hooks, isolation, permissions or permission, or sets readonly: true, disable-model-invocation: true, infer: false or disabled/disable: true (Claude, Copilot, Cursor and OpenCode docs linked in the code). Every other dropped key is named in a warning through a helper extracted from the Codex renderer, whose messages are unchanged.
Gemini identifies an agent by its 'name' while APM's collision and adoption checks compare file paths, so code-review.md with name: reviewer could shadow a user's reviewer.md unnoticed. Such an agent is now skipped with a warning naming the expected file.
…rosoft#4593) A package whose only agent is invalid leaves a .gemini tree holding only settings.json byte-identical, with no agents directory. In the project and -g installs the deployed agent is the only change under .gemini, so APM never writes trustedFolders.json or Gemini's acknowledgement store.
…microsoft#4593) The project lifecycle points the ref at a commit that does not exist, expects a non-zero exit, and checks that the deployed agent and the lockfile bytes are unchanged before restoring the valid ref.
…t#4593) The targets matrix and apm-usage skill now carry one complete list of the keys that skip an agent and the accepted tool forms, including the restriction keys, the name-equals-stem rule and the leading-underscore rule. The Gemini agents bullet is split into sub-bullets, upstream source links move to the integrator comment, and the producer guide notes that Gemini skips the whole agent rather than one field.
…icrosoft#4593) The project-scope Gemini lifecycle is hermetic (local git, no network) and takes about 4 s, so it now runs in the required PR-time job instead of only in the merge-group shards.
…icrosoft#4593) integrate_agents_for_target now calls a single _render_agent_for_target, which picks the renderer by format_id and always returns (rendered or None, links_resolved). The eager mkdir for copy and Codex targets is gone: _deploy_rendered_agent creates the parent only when it writes, so a package whose agents are all skipped leaves the target tree untouched. The render-then-adopt guard now refuses mkdir() in the agent loop (with a bypass mutation case), and the Codex link-resolution guard checks the new dispatch point. This settles the shape before Antigravity adds a renderer.
…ents (microsoft#4593) After microsoft#3714 local bundle install renders packed Markdown agents to Codex TOML, so the apm-usage sentence no longer says Codex agents are skipped; Gemini agents and Gemini commands still are.
…microsoft#4593) math.isnan() on an integer too large for a double raised OverflowError and aborted the whole agent loop. Gemini's js-yaml reads such a value as a string, which z.number() rejects, so the agent is now skipped with the usual warning and its siblings still deploy. A 308-digit value, which still fits a double and loads in Gemini v0.70.0, is kept.
…icrosoft#4593) Gemini's z.number().int().positive() checks the value, so max_turns: 10.0 and timeout_mins: 5.0 load in Gemini v0.70.0 but were skipped because Python parses them as floats. Both now pass when positive and integral. The same check rejects a positive integer too large for a double, which Gemini reads as a string and refuses; it was accepted before.
…icrosoft#4593) verbatim_destinations returned None only for Kiro, the other agent format that renders its output. Gemini agents are rendered too, so they now return None as well. Today a Gemini target already replays live because it also deploys commands, which the drift records do not map.
main takes changelog.d/<pr>.<section>.md fragments instead of lines under [Unreleased]; the entry text is unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…oft#4593) Gemini CLI reads agent frontmatter with js-yaml, a YAML 1.2 reader. It reads plain 1e3, 1e-3 or 0o17 as numbers. PyYAML resolves them by YAML 1.1 rules as strings and so writes them unquoted. An agent named 1e3, or with such a description or display_name, deployed but Gemini rejected it with "Expected string, received number". yaml_to_str gains an opt-in quote_strings mode that quotes every string value and keeps keys, numbers and booleans plain. The Gemini renderer uses it. Checked with loadAgentsFromDirectory from @google/gemini-cli-core 0.70.0: such agents now load and keep the exact string values.
…soft#4593) Gemini now carries the agents primitive, so the harness conformance contract generates HC-DEPLOY-01.agents cells for it at project and user scope. Add test_hc_deploy_01_agents on the surface-witness Scene kit (microsoft#5778): install checks the registry path, the lock row, the native frontmatter and body, and emits the OBLIGATION receipt; uninstall emits the absence receipt. List both cells as required in the ratchet. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>


Description
Deploy APM agents to Gemini CLI:
.gemini/agents/<name>.md(project) and~/.gemini/agents/<name>.md(-g), qualified against Gemini CLI v0.70.0.Gemini's loader rejects an agent file with any frontmatter key outside its schema (
agentLoader.ts), so a verbatim copy does not load. A newgemini_agentrenderer, modelled on the Kiro preflight and run before any adopt check or write:name(frontmatter or file stem),description,tools,model,display_name,temperature,max_turns,timeout_mins; drops other keys;toolsomitted, which Gemini documents as inheriting the parent session's tools (subagents);descriptionis missing;nameis not a slug; a tool is not a Gemini tool name (tools reference; the check mirrorsisValidToolName);modelis notinheritorgemini-*; or the source declares agent-scoped MCP servers,disallowedTools,permissionModeorkind: remote. No tool or model mapping across providers.Local bundle installs skip Gemini agents, as they already do Codex agents, because the bundle path copies files without the renderer. APM does not write Gemini's trust, acknowledgement or
agents.overridesstate.Issue and approved scope
Issue: Refs #2990
Human scope-approval comment: #2990 (comment) (approach confirmed in #2990 (comment)). Review contact: Daniel Meppiel (@danielmeppiel)
This is the Gemini half. Antigravity (
.agents/agents/,~/.gemini/config/agents/) follows in a second PR, which will close the issue.Correction to my design comment: I wrote that project agents "load only in a trusted folder". That holds only while folder trust is on. In v0.70.0
security.folderTrust.enableddefaults totrue(configuration reference);trusted-folders.mdstill says it is off by default. With trust off, project agents load (registry.ts). The docs in this PR state the default from the configuration reference.Evidence (Gemini CLI v0.70.0, the latest release)
Run in Docker with this branch's
apm; modelsgemini-3-flash-preview(others returned 503 or quota errors).loadAgentsFromDirectoryfrom@google/gemini-cli-core@0.70.0loads every APM-rendered file. The raw sources fail:Unrecognized key(s) in object: 'color', and for a Copilot-style agentname: Requiredand'handoffs', 'argument-hint', 'user-invocable', 'target'.gemini -p "@file-reader ..."calledinvoke_agentwithagent_name: "file-reader"and returned a marker that exists only in the read file. The subagent's own chat log shows it called onlyread_file(plus Gemini'scomplete_task) and reported no shell tool. The shell part was delegated toshell-runner(tools: [run_shell_command]), which calledrun_shell_command. Each subagent's log starts with only its delegated prompt.~/.gemini/acknowledgments/agents.jsonwith hashes equal tosha256of the APM-deployed files. Theninvoke_agentreached the projectfile-reader, whose log shows onlyread_file.apm installdeployed a changedfile-reader, a headless run gotSubagent 'file-reader' not founduntil it is acknowledged again. Gemini's acknowledgement prompt stays in effect. In v0.70.0 that prompt is interactive only (AppContainer.tsx), which the docs now say.Type of change
Testing
Tested locally
All existing tests pass (in a Python 3.12 container; the same 260 environment-dependent tests fail on unmodified
main, for exampletest_unix_install_ownership.pyandtest_governance_evidence.py)Added tests for new functionality
tests/unit/integration/test_gemini_agents.py: rendering, every rejection case, preflight before adopt, sibling isolation, reinstall/update, user-file protection, sync removal, link resolution, the tool-name check.tests/integration/test_gemini_agent_lifecycle.py(APMLifecycle): project and-ginstall, reinstall, restore of a deleted file, update, an agent that becomes invalid (stale copy and ledger row removed), recovery, uninstall; a user agent and.gemini/settings.jsonwithagents.overridesare left unchanged.req-tg-009conformance test for Gemini;CONFORMANCE.{md,json}regenerated.The new unit and lifecycle tests fail with the
agentsmapping reverted.CI lint chain, architecture guards and complexity ratchet pass.
Changelog
## [Unreleased]inCHANGELOG.md.Spec conformance (OpenAPM v0.1)
req-tg-009test for Gemini added;CONFORMANCE.{md,json}regenerated. No spec or manifest change: req-tg-009 already covers this.