Skip to content

fix(agent): rewrite deprecated VSCode tool names at Copilot deploy time (supersedes #2500, closes #2465) - #2519

Closed
Daniel Meppiel (danielmeppiel) wants to merge 6 commits into
mainfrom
supersede/pr-2500
Closed

fix(agent): rewrite deprecated VSCode tool names at Copilot deploy time (supersedes #2500, closes #2465)#2519
Daniel Meppiel (danielmeppiel) wants to merge 6 commits into
mainfrom
supersede/pr-2500

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

TL;DR

This PR rewrites deprecated VSCode Copilot built-in tool identifiers to their current namespaced form when APM deploys GitHub agents, so existing agent content keeps working without requiring source edits. This PR supersedes #2500 authored by Sergio Sisternes (@sergio-sisternes-epam). The original change is preserved with full commit authorship. Additional shepherd fold-ins are described below.

Closes #2465

supersedes #2500

apm-spec-waiver: deploy-time compat shim -- renames deprecated VSCode built-in tool identifiers to current namespaced form; no new normative APM behaviour, no spec extension

Problem (WHY)

  • GitHub agent deployment was still emitting deprecated VSCode Copilot tool names, which breaks exact-match tool lookup once the runtime expects only the namespaced identifiers.
  • The compatibility fix needed to happen at deploy time so existing checked-in agent content remains unchanged while deployed output is normalized.
  • The original PR fixed the rename path, but this superseding branch also had to resolve a separate merge-queue blocker: the Spec conformance waiver detector did not recognize apm-spec-waiver: inside GitHub squash commit bodies because GitHub prefixes each squashed commit message line with * .
  • Without the diagnostic fold-in, rewritten tool names would be silent, making deploy-time mutation harder to observe in the same way other per-format integration helpers already report their transforms.
  • Without the extra non-string test, the isinstance(t, str) guard would remain uncovered at the tool-list boundary.

Approach (WHAT)

Area Change
GitHub agent compat Added a rename map for 6 deprecated VSCode Copilot tool names and applied it while copying GitHub agent files for deployment.
Integrator wiring Routed both integrate_agents_for_target and the deprecated integrate_package_agents Copilot path through the GitHub-agent copy helper so both deployment paths normalize tool names.
Diagnostics Extended _copy_github_agent to accept diagnostics and package_name, then emit an info-level diagnostic when rewrites occur.
Tests Added the original rename-focused unit coverage plus a new test proving non-string tool entries pass through unchanged.
Docs Updated instructions-and-agents.md to list the old names explicitly, shorten the table cell, and call out the exact-match behavior.
Changelog Added an [Unreleased] Fixed entry describing the deploy-time compatibility shim.
Merge-queue gate Fixed mode_b_detector.sh so squash-commit bodies prefixed with * still match apm-spec-waiver: and correctly waive the Spec conformance gate.

Implementation (HOW)

  • src/apm_cli/integration/agent_integrator.py

    • Defines GITHUB_AGENT_TOOL_RENAMES.
    • Rewrites YAML frontmatter tool entries via _apply_github_agent_tool_renames().
    • Copies GitHub-agent content through _copy_github_agent(...), now with diagnostics and package_name so rewrites are reported consistently.
    • Wires the helper into both integrate_agents_for_target and the deprecated integrate_package_agents Copilot path.
  • tests/unit/integration/test_agent_integrator.py

    • Covers rename application, deploy-path wiring, unchanged behavior when no deprecated names are present, and the isinstance(t, str) guard through test_non_string_tool_entries_pass_through_unchanged.
  • docs/src/content/docs/producer/author-primitives/instructions-and-agents.md

    • Documents the deploy-time rename shim, names the deprecated identifiers explicitly, and explains the exact-match caveat for tool identifiers.
  • CHANGELOG.md

    • Adds an [Unreleased] Fixed entry for the compatibility rewrite.
  • tests/spec_conformance/mode_b_detector.sh

    • Adjusts waiver detection so merge-queue squash commit bodies that prefix lines with * still satisfy the waiver grep.

Trade-offs

  • This keeps the compatibility shim at deploy time instead of rewriting source content, which minimizes churn in checked-in agent files but preserves a transformation step in deployment.
  • The rename map is intentionally narrow: it only covers the known deprecated VSCode built-in identifiers rather than introducing broader fuzzy matching.
  • The deprecated integrate_package_agents path still receives the fix so older call paths behave correctly, even though that keeps compatibility logic alive in a legacy surface.
  • Emitting an info diagnostic adds a little more deploy output, but it makes the mutation observable and aligns this helper with other per-format integrator behavior.

Validation

Check Result
Ruff lint uv run --extra dev ruff check src/ tests/ && uv run --extra dev ruff format --check src/ tests/ -> All checks passed, 1610 files already formatted
Targeted unit tests uv run pytest tests/unit/integration/test_agent_integrator.py -q -> 82 passed in 1.66s
Mode B detector on branch BASE_REF=origin/main bash tests/spec_conformance/mode_b_detector.sh -> [!] mode_b: WAIVED (89 substantive added lines)
Mode B detector on squash-commit shape BASE_REF=FETCH_HEAD~1 GH_PR_BODY="" bash tests/spec_conformance/mode_b_detector.sh -> [!] mode_b: WAIVED

How to test

  1. Run uv run pytest tests/unit/integration/test_agent_integrator.py -q.
  2. Deploy or simulate GitHub-agent integration with agent frontmatter that includes one of the deprecated VSCode tool names and verify the emitted output uses the namespaced identifier instead.
  3. Repeat with a tool list containing a non-string entry and verify the non-string value passes through unchanged.
  4. Confirm the deploy path emits an info-level diagnostic when a rename occurs.
  5. Run BASE_REF=origin/main bash tests/spec_conformance/mode_b_detector.sh and then run BASE_REF=FETCH_HEAD~1 GH_PR_BODY="" bash tests/spec_conformance/mode_b_detector.sh to verify waiver detection in both cases.

Co-authored-by: sergio-sisternes-epam sergio-sisternes-epam@users.noreply.github.com
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Sergio Sisternes and others added 5 commits August 6, 2026 16:23
VSCode Copilot namespaced its built-in tool identifiers (e.g.
'askQuestions' -> 'vscode/askQuestions').  Any package that ships an
agent with old unnamespaced tool names in its 'tools:' frontmatter
triggers 'Tool or toolset has been renamed' warnings in the IDE after
'apm install --target copilot'.

Fix: add GITHUB_AGENT_TOOL_RENAMES mapping and apply it at deploy time
in _copy_github_agent().  The transform is wired into both the
target-driven integrate_agents_for_target (github_agent format_id) and
the legacy integrate_package_agents path.  Source package files are
never modified.

Six renames applied automatically:
  askQuestions       -> vscode/askQuestions
  runInTerminal      -> execute/runInTerminal
  getTerminalOutput  -> execute/getTerminalOutput
  createFile         -> edit/createFile
  fetch              -> web/fetch
  listDirectory      -> search/listDirectory

Added 12 regression tests covering the static helper, all six renames,
edge cases (no frontmatter, null/non-list tools, unknown names,
already-namespaced names), and both integration paths.

Updated instructions-and-agents.md: copilot row in the transform table
and a new 'Common pitfalls' entry for old tool names.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…_tool_renames

- Preserve non-string YAML entries (mappings, sequences) as-is instead of
  coercing everything with str() when a rename occurs
- Clarify docstring: 'semantically preserved' vs 'completely unchanged' to
  reflect that YAML roundtrip may alter formatting of unrelated keys

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… built-in tool identifiers to current namespaced form; no new normative APM behaviour, no spec extension

Co-authored-by: sergio-sisternes-epam <sergio-sisternes-epam@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Addresses apm-review-panel CEO follow-ups FU-1, FU-2, FU-4 and
Copilot test-coverage finding TC-1:

FU-1 (CL-1/DX-1): _copy_github_agent now accepts diagnostics and
package_name params matching the signature of every other per-format
helper. When tool names are rewritten and diagnostics is supplied, an
info-level message names the file and count of rewrites -- preserving
diagnostic parity with _write_codex_agent and _warn_opencode_frontmatter.
Both call sites in integrate_agents_for_target and
integrate_package_agents are updated to pass the collector through.

FU-2 (DW-1/DW-2/DW-3): instructions-and-agents.md pitfall entry now
lists both the old names (askQuestions, runInTerminal, getTerminalOutput,
createFile, fetch, listDirectory) alongside the new namespaced forms so
authors can audit existing source files without reading the code. Bold
label shortened from 'Old unnamespaced VSCode built-in tool names' to
'Deprecated VSCode built-in tool names'. Table cell shortened from
twelve words to four ('tool names rewritten; otherwise verbatim').
Exact-match caveat added (e.g. fetchData is unaffected).

FU-4: CHANGELOG [Unreleased] Fixed entry added framing the change as a
user-facing IDE-warning fix, not an internal refactor.

TC-1: Added test_non_string_tool_entries_pass_through_unchanged to
TestGithubAgentToolRenames covering the isinstance(t, str) guard path
for mapping nodes in the tools list alongside renamed string entries.

Co-authored-by: sergio-sisternes-epam <sergio-sisternes-epam@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
GitHub merge-queue squash commits prepend '* ' to each cherry-picked
commit message in the synthetic squash body. The Mode B detector's
grep pattern '^apm-spec-waiver:' did not match the prefixed form
'* apm-spec-waiver:', so the waiver set in commit 9e17395 was
silently ignored during merge-queue CI runs, causing repeated
Spec conformance failures even though the waiver was present.

Fix: extend the git-log grep to '^(\* )?apm-spec-waiver:' and strip
the optional '* ' prefix before extracting the rationale. The PR-body
path (GH_PR_BODY env) is unaffected -- it only fires on plain PR
triggers where the squash prefix cannot appear.

Verified against the synthetic squash commit from the merge queue run
gh-readonly-queue/main/pr-2500-3aa0365540e3d9ef4685740cea6a09094ff35377
(commit 0fc07a6): BASE_REF=FETCH_HEAD~1 mode_b_detector.sh exits 0
with the correct WAIVED message after this fix.

Co-authored-by: sergio-sisternes-epam <sergio-sisternes-epam@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The _copy_github_agent method emits a diagnostics.info() call that is
a new consumer of printable_ascii_text. Three fixes:

1. check_diagnostic_ascii_owner.py: add 'info' to the set of method
   names covered by _diagnostic_calls(), and add
   AgentIntegrator._copy_github_agent to AGENT_DIAGNOSTIC_FUNCTIONS
   (require_source=False, same as _warn_opencode_frontmatter) so the
   checker enforces the boundary on both package_name and source.name.

2. agent_integrator.py: wrap source.name with printable_ascii_text()
   in the info() message, matching the same pattern used by
   _warn_codex_unverified_scope and _warn_codex_tools_dropped.

3. test_check_diagnostic_ascii_owner.py: update
   test_opencode_wrapper_package_field_must_use_owner to target the
   second occurrence of the pattern (the first is now in
   _copy_github_agent), and add
   test_copy_github_agent_package_field_must_use_owner to cover the
   new consumer.

Fixes Build & Test Shard 2 failure on supersede/pr-2500 CI.

Co-authored-by: sergio-sisternes-epam <sergio-sisternes-epam@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a deploy-time compatibility shim for the copilot (github_agent) target by rewriting deprecated VSCode Copilot built-in tool identifiers (e.g., fetch) into their current namespaced forms (e.g., web/fetch) when deploying *.agent.md files, keeping existing package sources unchanged. It also updates the spec-waiver detector to recognize waiver trailers inside GitHub squash-commit bodies that prefix lines with * .

Changes:

  • Add a github_agent-specific frontmatter transform that renames deprecated VSCode Copilot tool identifiers during agent deployment, and wire it into both the current and deprecated deployment paths.
  • Emit an info diagnostic when a rewrite occurs, and add unit tests (including coverage for non-string tools: entries).
  • Update documentation + changelog to describe the deploy-time rewrite, and harden the spec conformance waiver detector for merge-queue squash commits.
Show a summary per file
File Description
src/apm_cli/integration/agent_integrator.py Adds the rename map + YAML-frontmatter rewrite and routes GitHub-agent deployment through the new copy helper with diagnostics.
tests/unit/integration/test_agent_integrator.py Adds unit/integration coverage for the rename behavior and non-string tools: entries.
tests/spec_conformance/mode_b_detector.sh Updates waiver detection to match * apm-spec-waiver: lines in squash commit bodies.
docs/src/content/docs/producer/author-primitives/instructions-and-agents.md Documents that Copilot deployment rewrites deprecated tool names and lists the old/new identifiers.
CHANGELOG.md Adds an Unreleased “Fixed” entry describing the deploy-time compatibility rewrite.

Review details

  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment on lines +426 to +434
if renamed is not content and diagnostics is not None:
count = sum(1 for old in GITHUB_AGENT_TOOL_RENAMES if old in content)
diagnostics.info(
message=(
f"{source.name}: rewrote {count} deprecated"
f" VSCode tool name(s) to namespaced form"
),
package=printable_ascii_text(package_name),
)
Comment thread CHANGELOG.md
Comment on lines +16 to +18
Package source files are never modified. Eliminates "Tool or toolset has
been renamed" IDE warnings without any source changes. (by
@sergio-sisternes-epam; closes #2465) (#2500)
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Shepherd summary (supersedes #2500)

This PR was opened by the apm-review-panel shepherd loop after the original PR #2500 could not be updated (branch was locked in the merge queue whose Spec conformance gate was failing).

Root causes identified and fixed in this PR:

  1. [SPEC-GATE] mode_b_detector.sh was not detecting the apm-spec-waiver token in GitHub merge-queue squash commit bodies. GitHub prefixes cherry-picked commit messages with '* ' in the squash body; the grep pattern '^apm-spec-waiver:' did not match. Fixed in commit f9d3473.
  2. [LINT-GATE] Build & Test Shard 2 failed because _copy_github_agent is a new diagnostics consumer. check_diagnostic_ascii_owner.py was extended to cover it; source.name wrapped with printable_ascii_text; test updated. Fixed in commit f590206.

Panel verdict: ship_now (no blocking findings, no security concerns, 82 tests passing)

Folds from advisory panel:

  • Verbose-level diagnostic added to _copy_github_agent (diagnostic parity with other per-format helpers)
  • Docs: pitfall entry lists old tool names explicitly; table cell shortened; exact-match caveat added
  • CHANGELOG [Unreleased] Fixed entry added
  • Test for non-string tool entries (isinstance guard)

Deferred:

  • copy_agent pre_transform refactor (FU-3) -- crosses into existing API used by all format paths; follow-up issue recommended

CI on this PR: all 18 checks green at f590206.

#PR sha CEO stance iter folds deferrals copilot ci mergeable merge state notes
#2519 f590206 ship_now 1 6 1 1 green MERGEABLE BLOCKED pending required review

Advisory comment on original PR: #2500 (comment)

@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

All shepherd folds (including copy_agent pre_transform unification from FU-3, mutation-break gates for all 3 regression traps, and full lint/CI evidence) have been pushed directly onto the original branch sergio-sisternes-epam-fix-agent-tools-frontmatter-rename-2465 via force-with-lease. PR #2500 is now the canonical landing target at head 8e169e5. Closing this superseding PR.

@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Superseded by original PR #2500 which now carries the complete folded history. Closing.

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.

[BUG] Tool or toolset has been renamed in agent.md tools front matter

2 participants