Skip to content

Trim AGENTS.md of duplicate content#12003

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
masterfrom
mcculls/trim-agents.md
Jul 22, 2026
Merged

Trim AGENTS.md of duplicate content#12003
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
masterfrom
mcculls/trim-agents.md

Conversation

@mcculls

@mcculls mcculls commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Motivation

Reduces AGENTS.md by 25% while still keeping critical advice close by

Contributor Checklist

Jira ticket: APMLP-1609

@mcculls
mcculls requested a review from a team as a code owner July 20, 2026 13:24
@mcculls mcculls added the comp: core Tracer core label Jul 20, 2026
@mcculls
mcculls requested a review from PerfectSlayer July 20, 2026 13:24
@mcculls mcculls added type: documentation tag: no release notes Changes to exclude from release notes labels Jul 20, 2026
@mcculls
mcculls requested review from Copilot and jordan-wong July 20, 2026 13:24
@mcculls

mcculls commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot 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.

Datadog Autotest: PASS

More details

Documentation refactoring that consolidates duplicate content from AGENTS.md into dedicated, detailed guideline files. All critical constraints (bootstrap, instrumentation/advice) are preserved with enhanced explanations and code examples. Referential integrity verified — all links resolve correctly.

Was this helpful? React 👍 or 👎

📊 Validated against 5 scenarios · Open Bits AI session

🤖 Datadog Autotest · Commit 8832d8c · What is Autotest? · Any feedback? Reach out in #autotest

@mcculls
mcculls requested a review from bric3 July 20, 2026 13:27
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 8832d8c539

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Copilot AI 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.

Pull request overview

This PR trims duplicated guidance from AGENTS.md by moving instrumentation/advice-specific constraints into a dedicated documentation page, while keeping concise links and critical reminders in AGENTS.md. It also centralizes the static-import guidance in CONTRIBUTING.md so the main contributor doc remains the source of truth.

Changes:

  • Added a new docs/instrumentation_design_guidelines.md document capturing key advice/instrumentation constraints and examples.
  • Updated AGENTS.md to link to the new instrumentation/advice guidelines and to reduce duplicated sections (static imports, perf review, and critical constraints).
  • Added an explicit “Static imports” section to CONTRIBUTING.md to serve as the primary reference.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
docs/instrumentation_design_guidelines.md New focused doc for instrumentation/advice constraints (one-shot methods, scope lifecycle ordering, static interface methods in advice).
CONTRIBUTING.md Adds a dedicated static-imports section to make CONTRIBUTING the canonical reference.
AGENTS.md Removes duplicated details, adds links to the new guidelines, and keeps critical constraints as concise bullets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread AGENTS.md
@mcculls
mcculls requested review from a team and bm1549 July 20, 2026 13:36

@bm1549 bm1549 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.

Most of my questions are if we can convert some of the prose into static analysis

Even if the static checks are hacky, it pays dividends in token usage since it lets us shorten the instructions for LLMs while providing stronger guarantees

Comment thread AGENTS.md
Calling a static interface method there, such as Context.root() or Context.current(), can cause
a VerifyError at runtime — use Java8BytecodeBridge (rootContext, currentContext, etc.) instead.
- **Bootstrap**: never use `java.util.logging.*`, `java.nio.file.*`, or `javax.management.*` in `premain` code — see [docs/bootstrap_design_guidelines.md](docs/bootstrap_design_guidelines.md).
- **Advice**: never call a static interface method from advice — can cause a `VerifyError` — see [docs/instrumentation_design_guidelines.md](docs/instrumentation_design_guidelines.md).

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.

[optional suggestion] Is it possible to have this as static analysis, rather than prose? If so, we can spend the tokens on this up-front rather than having every agent need to read this and enforce it every time

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The tricky part is identifying advice classes which must avoid static interface methods, vs helpers which don't need to (where doing that would just add fluff) - it's basically methods annotated with @Advice.OnMethodEnter / @Advice.OnMethodExit but we'd need to roll our own analyzer to filter on that ... or expand instrumentation-annotation-processor to also dig into the advice bytecode.

That's possible but that also would just add a guard - it's still helpful to flag the existence of Java8BytecodeBridge and guide the agent to do the right thing to begin with.

@bm1549 bm1549 Jul 20, 2026

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.

Depending on how prevalent it is through the codebase, the analyzer could either run everywhere and be suppressed in the locations where it's safe or we could make the finer-grained targeting you're describing

As for guarding vs guiding, you can do both but as the models evolve, guarding tends to be the piece that survives while the guiding bits can be deleted

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Basically I've had agents introduce static interface methods a lot during recent refactorings and it's been annoying to remind them not to do this - a guard would stop them from reaching a reviewable PR, but you'd still have that loop of a) initial refactor b) fails build check c) find alternative (Java8BytecodeBridge) d) fix code e) pass build check

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.

Yep that's correct, so having both would be the belt-and-suspenders so to say

@jordan-wong jordan-wong Jul 21, 2026

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.

I do agree with this, generally I imagine this as a funnel where we generally:

  • use skills as a catch-all for advice/ documentation, there will be items that only apply to specific situations where an LLM can figure out when theyre relevant
  • certain parts we can figure out where to encode as general static checks
  • we generally move from skill -> static checks as we refine the skills/ optimize

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agree, will look into this as a follow-up item

Comment thread AGENTS.md

- **Formatting**: google-java-format enforced via Spotless. Run `./gradlew spotlessApply` before committing.
- **Static imports**: Prefer static imports over class-qualified calls for call-style helpers — JUnit `Assertions`, Mockito (`mock`, `when`, `verify`, `anyString`, `RETURNS_DEFAULTS`, ...), Hamcrest/AssertJ matchers, internal test DSLs, and similar. Same goes for production code: `Collections.emptyList()` is fine, but if you find yourself repeatedly writing `Foo.bar(...)` where `Foo` adds no information at the call site, static-import `bar`. Wildcard `import static x.*` is disallowed (enforced by IDE config in CONTRIBUTING.md).
- **Static imports**: Prefer static imports over class-qualified calls for call-style helpers, in both test (Assertions.assertEquals, Mockito.mock) and production code (Collections.emptyList). Wildcard imports disallowed — see CONTRIBUTING.md.

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.

Wildcard imports disallowed

Isn't this already part of the formatter? What reason is it here as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The formatter will detect use of wildcard imports, but it won't tell you to avoid continually writing Collections.emptyList() tens of times in the same file and instead prefer to static import Collections.emptyList and then use emptyList() everywhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So we can drop the bit about wildcard imports, but we still need the rest

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.

The formatter will detect use of wildcard imports, but it won't tell you to avoid continually writing Collections.emptyList() tens of times in the same file and instead prefer to static import Collections.emptyList and then use emptyList() everywhere.

Is there a benefit to doing this or is this just personal preference for the codebase?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Helps readability - we've found agents don't use static imports as much, and that can make the code harder to read - especially for APIs that were designed to be used with static imports like JUnit/Mockito

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.

Not blocking, but is there any path to doing these as static analysis as well? Said differently, is there a big downside to a static import for a single emptyList()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will look into that as a follow-up item

@dd-octo-sts

dd-octo-sts Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.00 s 13.94 s [-0.3%; +1.2%] (no difference)
startup:insecure-bank:tracing:Agent 12.99 s 13.04 s [-1.3%; +0.5%] (no difference)
startup:petclinic:appsec:Agent 16.88 s 16.80 s [-0.6%; +1.5%] (no difference)
startup:petclinic:iast:Agent 16.77 s 16.90 s [-1.5%; -0.1%] (maybe better)
startup:petclinic:profiling:Agent 16.78 s 16.66 s [-0.4%; +1.9%] (no difference)
startup:petclinic:sca:Agent 16.89 s 16.60 s [+0.9%; +2.7%] (maybe worse)
startup:petclinic:tracing:Agent 16.04 s 16.07 s [-1.2%; +0.8%] (no difference)

Commit: 8832d8c5 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@jordan-wong jordan-wong 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.

  • no notes on content, LGTM
  • In future it would be nice to consider the idea of seeing what we can move to static checks, which will help to optimize skills (slimming down to not overload context). There is a point that we want to give context to agents AS it's generating code, not after, I imagine this requires some nuance per case (some things are harder for agents to conform to when it's just in skill vs static check)

@PerfectSlayer PerfectSlayer 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.

Approving. I would not push for static analyzer in this PR as the goal was to reduce the size of agents.md
I agree that's an interesting idea but I would rather see the agents file addressed, and improve checker later.

@datadog-datadog-prod-us1-2

This comment has been minimized.

@mcculls
mcculls added this pull request to the merge queue Jul 22, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 22, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-22 09:51:28 UTC ℹ️ Start processing command /merge


2026-07-22 09:51:33 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-07-22 11:26:35 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 22, 2026
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit c7901a5 into master Jul 22, 2026
590 of 593 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the mcculls/trim-agents.md branch July 22, 2026 11:26
@github-actions github-actions Bot added this to the 1.65.0 milestone Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: core Tracer core tag: no release notes Changes to exclude from release notes type: documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants