Skip to content

azure-devops-cli: handle long comments on Windows (#2061)#2140

Open
KomalSrinivasan wants to merge 1 commit into
github:mainfrom
KomalSrinivasan:fix/issue-2061-azps-windows
Open

azure-devops-cli: handle long comments on Windows (#2061)#2140
KomalSrinivasan wants to merge 1 commit into
github:mainfrom
KomalSrinivasan:fix/issue-2061-azps-windows

Conversation

@KomalSrinivasan

@KomalSrinivasan KomalSrinivasan commented Jun 26, 2026

Copy link
Copy Markdown

Closes #2061.

@gcapnias flagged that long Azure DevOps comments fail on Windows because az resolves to az.cmd, a cmd.exe batch wrapper capped at ~8191 characters. The agent then burns 3-5 turns falling back to raw token retrieval and REST calls instead of reaching for azps.ps1 (the PowerShell entry that bypasses the cap).

This PR teaches the skill three verified ways out, picked in priority order, so the agent routes correctly the first time.

What the skill now documents

skills/azure-devops-cli/SKILL.md picks up a Posting long comments on Windows section placed before the Reference Files table so it lands in the agent's context window early:

  1. Shell detection table so the agent knows when the cap actually applies (cmd.exe-wrapped az on Windows) versus when plain az is fine (PowerShell or bash on macOS / Linux).
  2. Option 1: azps.ps1 in PowerShell on Windows. Same Azure CLI invoked through the Python entry point with no cmd.exe cap. Paired with Get-Content -Raw so the body lives in a variable.
  3. Option 2: native --file-path flags where the Azure CLI offers them. Applies to az devops wiki page create / update (verified against the official command reference, both take --file-path plus --encoding).
  4. Option 3: az devops invoke --in-file as the universal escape hatch for commands with no --file-path (--discussion, --description). Worked example posts to POST /{project}/_apis/wit/workItems/{id}/comments?api-version=7.0-preview.3, which is the documented Work Item Comments REST endpoint.

skills/azure-devops-cli/references/boards-and-iterations.md picks up short pointers right next to the two --discussion examples (az boards work-item create and az boards work-item update) so the pattern is visible at point of use, plus an inline PowerShell snippet showing the Get-Content -Raw + azps.ps1 flow.

What changed since the first draft of this PR

The earlier draft also recommended the Azure CLI @<file> convention as a universal substitute for inline string args. On a second pass I checked:

  • The official quoting guide only documents @<file> for JSON parameters.
  • The CLI core implements file loading via get_file_json, which is JSON-specific.
  • No Azure docs or issues confirm @<file> expands plain string args like --discussion.

So I pulled the @file recommendation and added an explicit Don't rely on @<file> for plain string args warning instead. The three options that ship now are all backed by official Microsoft documentation:

Verification

  • npm run build exits 0, regenerates marketplace.json cleanly.
  • npm run skill:validate reports azure-devops-cli as valid. (The validator surfaces an unrelated upstream issue in aws-cloudwatch-investigation; out of scope here.)
  • git diff --stat main shows 2 files touched. No README diff because the skill description field is unchanged.

Out of scope

  • az repos pr create / update --description. The same routing applies (use azps.ps1 or az devops invoke) and SKILL.md says so generically, but I left the repos-and-prs.md examples alone to keep the diff tight. Happy to extend if maintainers want.

@github-actions github-actions Bot added the skills PR touches skills label Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔒 PR Risk Scan Results

Scanned 2 changed file(s).

Severity Count
🔴 High 0
🟠 Medium 0
ℹ️ Info 0

✅ No matching risk patterns were detected in changed files.

This is an automated soft-gate report. Findings indicate review targets and do not block merge by themselves.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🔍 Skill Validator Results

⚠️ Warnings or advisories found

Scope Checked
Skills 1
Agents 0
Total 1
Severity Count
❌ Errors 0
⚠️ Warnings 1
ℹ️ Advisories 0

Summary

Level Finding
ℹ️ Found 1 skill(s)
ℹ️ [azure-devops-cli] 📊 azure-devops-cli: 1,726 BPE tokens [chars/4: 1,740] (detailed ✓), 20 sections, 6 code blocks
ℹ️ [azure-devops-cli] ⚠ No numbered workflow steps — agents follow sequenced procedures more reliably.
ℹ️ ✅ All checks passed (1 skill(s))
Full validator output
Found 1 skill(s)
[azure-devops-cli] 📊 azure-devops-cli: 1,726 BPE tokens [chars/4: 1,740] (detailed ✓), 20 sections, 6 code blocks
[azure-devops-cli]    ⚠  No numbered workflow steps — agents follow sequenced procedures more reliably.
✅ All checks passed (1 skill(s))

On Windows 'az' is a cmd.exe batch wrapper capped at ~8191 characters,
so a long --discussion / --description value silently truncates or
fails. Document three verified ways out so the coding agent doesn't
waste 3-5 turns falling back to raw token retrieval and REST:

1. azps.ps1 in PowerShell on Windows. Same Azure CLI, invoked through
   the Python entry point with no cmd.exe length cap. Pair with
   'Get-Content -Raw' so the body lives in a variable, not on the
   command line.

2. Native --file-path flags where Azure CLI offers them. Applies to
   'az devops wiki page create' and 'az devops wiki page update', both
   documented with --encoding.

3. 'az devops invoke --in-file' as the universal escape hatch for
   commands with no --file-path (work-item --discussion, PR
   --description). Documented example posts to the work item
   comments REST endpoint with api-version 7.0-preview.3.

The earlier draft suggested the Azure CLI '@<file>' convention as a
generic substitute for inline string args. The official docs only
document it for JSON parameters and the CLI source uses
'get_file_json' specifically, so the claim is removed and replaced
with an explicit warning not to rely on it for plain string args.

Files touched:
- skills/azure-devops-cli/SKILL.md: new 'Posting long comments on
  Windows' section with shell-detection table and three verified
  options.
- skills/azure-devops-cli/references/boards-and-iterations.md: short
  pointer at each --discussion example back to SKILL.md, plus an
  inline PowerShell snippet.

Closes github#2061.
@KomalSrinivasan KomalSrinivasan force-pushed the fix/issue-2061-azps-windows branch from e565871 to 0754522 Compare June 26, 2026 21:57
@github-actions github-actions Bot added the skill-check-warning Skill validator reported warnings label Jun 26, 2026
@KomalSrinivasan KomalSrinivasan changed the title azure-devops-cli: handle long comments on Windows (#2061) 🤖🤖🤖 azure-devops-cli: handle long comments on Windows (#2061) Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skill-check-warning Skill validator reported warnings skills PR touches skills

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azure-devops-cli skill erratic behavior

1 participant