Skip to content

[copilot] Refine agent guidance from session review - #13778

Merged
simonrozsival merged 6 commits into
mainfrom
dev/simonrozsival/agent-instructions-2026-11-25
Nov 27, 2026
Merged

simonrozsival merged 6 commits into
mainfrom
dev/simonrozsival/agent-instructions-2026-11-25

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Context: #13521
Context: #13728
Context: #13790

An expanded review of all stored conversation turns in 1,558 remaining local dotnet/android candidate sessions found recurring test-scope churn, overbuilt solutions, and build/environment validation pitfalls. The review used 50 subagents; 1,486 sessions had stored turns and 72 had none. The candidate filter can include non-coding conversations, and stored turns are not full raw tool transcripts.

Test and review guidance

Test additions repeatedly needed scope reductions when they duplicated existing coverage, asserted implementation shape, or used brittle GC-timing assumptions. The guidance now emphasizes unique behavioral or regression protection while preserving meaningful characterization tests. The code-review skill no longer requires a comment on clean PRs or a full-file read when relevant context is sufficient.

Build and runtime experiments

The review confirmed shared SDK/JDK path hazards and missing submodule prerequisites; local-build guidance now checks resolved paths, and the tests skill now lists the SourceLink workaround next to standalone dotnet test, where agents in fresh worktrees hit it. Manual submodule guidance already merged in #13780; automatic initialization is a separate build change in #13797, with no build-code changes here. Historical make all failures predate the existing make leeroy guidance. In one requested runtime experiment, successful builds and dotnet test --no-build exercised baseline rather than candidate artifacts, so the device skill now advises verifying manually replaced APK/native-library candidates.

Correctness and shortening

Review rules contained inaccurate test-fixture, JNI, GC, and Android stack claims; these were corrected. MSBuild guidance now permits skipping incrementality when required side effects or incomplete inputs/outputs make it unsafe, and avoids requiring helper targets for inputs already available during evaluation. Rebasing onto main preserves #13790's task-hosting rules, Condition/DependsOnTargets ordering, and Java.Interop target-framework corrections unchanged rather than duplicating or replacing them.

The always-loaded instructions now enable NRT for new code without converting existing code unless asked. Duplicated commands, examples, and unconditional rules were removed or shortened.

Net change against the rebased main: −138 lines (+52/−190 across 11 instruction/skill files); copilot-instructions.md shrinks from 287 to 150 lines.

Validation: git diff --check origin/main...HEAD passed. Compared the rebased Java.Interop instructions, MSBuild review rules, and Java.Interop build-configuration documentation with main; all are unchanged. Builds and tests were not run, per instruction; this PR only updates documentation and agent instructions.

@simonrozsival simonrozsival changed the title [docs] Discourage low-value tests and trim agent instructions [docs] Refine agent guidance from session review Nov 25, 2026
@simonrozsival simonrozsival changed the title [docs] Refine agent guidance from session review [copilot] Refine agent guidance from session review Nov 25, 2026
simonrozsival added a commit that referenced this pull request Nov 25, 2026
…13780)

Context: #13778

`external/android-api-docs` is the repo's only submodule, and new git worktrees don't initialize it. Neither `make prepare` nor any agent instruction mentions it. Builds in such worktrees run for several minutes and then fail during packaging:

```
sharedfx.targets(413,5): error MSB4018: System.IO.FileNotFoundException: .../bin/Release/lib/xamarin.android/xbuild-frameworks/Microsoft.Android/37/Mono.Android.xml
```

`_ExportMsxDoc` reads `external/android-api-docs/docs/xml` (`src/Mono.Android/Mono.Android.targets`), so `Mono.Android.xml` is never produced.

A review of local agent sessions found this pattern repeatedly:

  * 30 sessions ran `git submodule update --init external/android-api-docs` by hand, and 37 hit the error above.
  * Each occurrence cost about 10 minutes: a failed `make leeroy`, a search through a ~20k-line log, and a rebuild.
  * Some orchestration prompts had started carrying "`git submodule update --init --recursive` if needed" as a workaround.

This adds one bullet to the `local-build` skill: in a new worktree, run `git submodule update --init` before building. The bullet includes the error text, so an agent that has already hit the failure can recognize it. The always-loaded instructions are unchanged.

Making `make prepare` initialize the submodule would remove the step entirely, but it is a build-system change and is not part of this PR.
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/agent-instructions-2026-11-25 branch from 448674f to e4a5a93 Compare November 26, 2026 13:47
@simonrozsival
simonrozsival marked this pull request as ready for review November 26, 2026 14:12
Copilot AI balanced review requested due to automatic review settings November 26, 2026 14:12

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.

🟡 Changes recommended

Loaded review references still contradict the updated MSBuild and interop guidance, risking incorrect incrementality requirements, disposal of borrowed JNI references, and unnecessary callback changes.

2 open issues
What changed in this PR

Refines .NET for Android’s agent guidance based on session reviews, building on earlier instruction updates without changing product or build code.

Changes:

  • Focuses test additions and review comments on meaningful, substantiated issues.
  • Improves guidance for shared build environments, SDK selection, and verifying deployed experimental artifacts.
  • Shortens common instructions and corrects MSBuild, nullable, JNI, and runtime guidance.
File Description
.github/​skills/​tests/​SKILL.md Adds a SourceLink workaround and links shared validation guidance.
.github/​skills/​local-build/​SKILL.md Clarifies SDK selection, safe cleanup, and shared-toolchain risks.
.github/​skills/​code-review/​SKILL.md Removes comment quotas and mandatory full-file reads.
.github/​skills/​code-review/​references/​testing-rules.md Makes testing guidance fixture-specific and behavior-focused.
.github/​skills/​code-review/​references/​native-rules.md Removes an inaccurate Android thread-stack claim.
.github/​skills/​code-review/​references/​interop-rules.md Corrects JNI ownership, callback, exception, and environment guidance.
.github/​skills/​code-review/​references/​csharp-rules.md Clarifies nullable and comparison rules; removes inaccurate blanket advice.
.github/​skills/​code-review/​references/​ai-pitfalls.md Discourages low-value tests and skipping failed assertions.
.github/​skills/​android-devices/​SKILL.md Adds deployed-candidate verification for manual experiments.
.github/​instructions/​msbuild.instructions.md Qualifies incrementality requirements and late-bound input handling.
.github/​copilot-instructions.md Consolidates testing, nullable, formatting, and troubleshooting guidance.

Review effort: Balanced

@PeppersMuse PeppersMuse left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed as PeppersMuse. The guidance cleanup itself reads well, but I found two places where this PR's corrections are contradicted by review rules that are still loaded — so a reviewer following the skill would be told to flag exactly what the authoring guidance now allows. Details are inline below.

I also read through the rest of the diff (copilot-instructions.md trimming, testing-rules.md, csharp-rules.md, native-rules.md, local-build/tests skills): the softenings there are consistent with the PR's stated purpose and I found nothing else to flag.

simonrozsival added a commit that referenced this pull request Nov 26, 2026
Context: #13430
Context: #13780

A review found missing `external/android-api-docs` initialization in 22 local agent sessions. Fresh worktree builds fail late when `Mono.Android.xml` cannot be produced, even though the Unix and Windows build guides say preparation updates submodules. The `Prepare` target did not actually run that step.

Run `git submodule update --init -- external/android-api-docs` from the repository root before the bootstrap builds. Both `make prepare` and solution preparation on Windows use this target. Git checks out the pinned submodule revision rather than following its upstream branch; when already at that revision, no checkout is needed. Initialization or checkout errors stop preparation instead of surfacing much later. Update the build guides to name the submodule explicitly.

### Relationship to other changes

#13780 already merged agent-facing manual initialization guidance. This change addresses the build itself and contains no `.github/` edits, so it does not overlap the open `[copilot]` PRs (#13766, #13778, #13782, #13783, #13784, #13785).

#13430 replaces preparation entry points but retains the `Prepare` target and does not initialize this submodule. Its `Prepare.proj` hunk was checked to apply on top of this change. It also rewrites both guide paragraphs edited here; if this merges first, keep #13430's replacement guide wording when resolving those documentation conflicts.
simonrozsival and others added 6 commits November 26, 2026 22:02
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Recurring findings from the agent session review: invalid performance
comparisons (~13 findings), flaky-test fixes that erased the test's oracle
or miscounted retries (~12), and removals that missed generated, packaging
or CI consumers (~10).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the agent-instruction changes in this PR and submit each on-demand skill separately for focused review.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Move the SourceLink workaround next to the standalone dotnet test commands
and leave api-docs submodule guidance to #13780.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep review rules consistent with ownership-aware JNI handling and MSBuild targets with required side effects. Update the local build instructions now that preparation initializes the API documentation submodule.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/agent-instructions-2026-11-25 branch from e4a5a93 to 88a027b Compare November 26, 2026 21:03
@simonrozsival

Copy link
Copy Markdown
Member Author

@dalexsoto review

@simonrozsival
simonrozsival enabled auto-merge (squash) November 27, 2026 10:31
@dalexsoto

Copy link
Copy Markdown
Member

In response to @simonrozsival's request: I have checked the changed rules and the resolved review threads, but still need to verify the retained AndroidSdk-Tests flags in test-catalog.md:39-40, the pinned ExceptionOccurred local-reference contract and generated SafeInvoke call sites, and the solution Prepare-to-submodule initialization path, then finish the unchanged context of the 13 edited files. My lookup of src/Java.Interop/Java.Interop/JniEnvironment.g.cs returned HTTP 404; the correct generated declaration is not located yet. These are gaps in my reviewer coverage, not defects found in this PR. I am retaining the completed checks to resume those specific items.

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed all 13 changed instruction and skill files, their cross-references, and the affected JNI, test-catalog and build-preparation guidance. The JNI ownership/SafeInvoke and MSBuild side-effect corrections are consistent across the loaded review references; the earlier review-thread concerns are resolved. No blocking issues found. Static review only; no builds or tests executed.

@simonrozsival
simonrozsival merged commit 54d669a into main Nov 27, 2026
39 checks passed
@simonrozsival
simonrozsival deleted the dev/simonrozsival/agent-instructions-2026-11-25 branch November 27, 2026 11:38
simonrozsival added a commit that referenced this pull request Nov 27, 2026
Context: #13778

A review of the last two days of local agent sessions found that agents in more than 12 sessions added tests that the maintainer later asked to delete. The deleted tests were overfitted to the implementation, flaky, or redundant, and each removal cost extra review turns and device-test reruns. Three sources pushed agents to add these tests:

  * Generic agent and harness defaults say to add a focused regression test.
  * Coordinator kickoffs required tests from every child session.
  * The `android-reviewer` workflow listed "missing tests" as a review priority above duplication. On one PR it asked for three sets of on-device tests, and the maintainer then trimmed them to one.

The guidance from #13778 rated tests by value but did not override these defaults, so agents still added tests by default. The instructions now say:

  * Default to no new tests. This explicitly overrides generic "add a regression test" defaults.
  * Add at most the single most valuable test, and only when the user asks for one or a real regression would otherwise be unprotected.
  * Push back on reviewer and bot requests for more tests.
  * Don't mandate tests in child-session kickoffs.
  * Reviewers (`android-reviewer`, and the `code-review` skill's testing rules) request a test only for an unprotected real regression, and never as a default.
  * The Java.Interop instructions defer to the top-level rule instead of repeating their own rule.

Other recurring issues:

  * **Scope:** "Keep it simple" now says to leave unrelated cleanups for separate PRs and to keep the user's earlier decisions. Maintainers repeatedly asked agents to shrink oversized diffs or move unrelated edits out.
  * **Restore:** the `tests` skill now says to omit `--no-restore` from test commands in new worktrees and scratch projects. That flag caused about 60 NETSDK1004 build failures across 19 sessions.
  * **NuGet:** Direct nuget.org requests by local agents can trigger blocked-access prompts even though the repo config uses Azure DevOps feeds. Direct package lookups and tool installs to those feeds, including `dotnet-public`, and explicitly restore scratch projects with that config.

Net change: +17/−10 lines. The `android-reviewer.lock.yml` file loads `android-reviewer.md` at runtime, so it does not need to be recompiled.
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.

4 participants