Skip to content

docs(agents): add explicit comments policy to AGENTS.md - #3502

Merged
juanmichelini merged 1 commit into
mainfrom
openhands/comments-policy-agents-md
Jun 4, 2026
Merged

juanmichelini merged 1 commit into
mainfrom
openhands/comments-policy-agents-md

Conversation

@juanmichelini

@juanmichelini juanmichelini commented Jun 4, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Issue #3498 calls out that agent-authored PRs (especially on Claude Opus 4.7/4.8 — see the analysis in #3498) often add long, narrative comment blocks that:

  • restate what the code already says,
  • summarize the surrounding diff / PR description,
  • describe non-local parts of the system with no way to stay in sync.

The reporter asked specifically for an explicit "comments policy" item in the SDK contributor guidelines, e.g. AGENTS.md <CODE> section.

Summary

  • Adds a new "Comments policy" bullet (with sub-bullets) to the <CODE> section of root AGENTS.md, covering:
    • prefer self-explanatory code over prose,
    • don't restate code, narrate the diff, or paraphrase the PR description (that's what the PR / git blame are for),
    • don't describe non-local behavior in comments without a sync mechanism (it drifts),
    • DO comment on genuinely unintuitive things (invariants, workarounds, ordering/locking, deliberate trade-offs),
    • a 3-line change shouldn't produce 19 lines of comments — direct callback to the PR cited in the issue.

Issue Number

Closes #3498

How to Test

Documentation-only change. Verified by:

  • Re-reading the <CODE> section of AGENTS.md to confirm the new policy is consistent in tone/structure with the surrounding bullets.
  • uv run pre-commit run --files AGENTS.md — passes (no hooks apply to Markdown files in this repo's pre-commit config, so it correctly skips).

No code/runtime behavior changes, so no automated tests were added per the contributor checklist (You do NOT need to write new tests if there are only changes to documentation or configuration files.).

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

This PR was created by an AI agent (OpenHands) on behalf of @juanmichelini in response to #3498.

@juanmichelini can click here to continue refining the PR


Agent Server images for this PR

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python amd64, arm64 nikolaik/python-nodejs:python3.13-nodejs22-slim Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:83dbe2b-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-83dbe2b-python \
  ghcr.io/openhands/agent-server:83dbe2b-python

All tags pushed for this build

ghcr.io/openhands/agent-server:83dbe2b-golang-amd64
ghcr.io/openhands/agent-server:83dbe2bb6b39eab11a921fe19551c1486af1e170-golang-amd64
ghcr.io/openhands/agent-server:openhands-comments-policy-agents-md-golang-amd64
ghcr.io/openhands/agent-server:83dbe2b-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:83dbe2b-golang-arm64
ghcr.io/openhands/agent-server:83dbe2bb6b39eab11a921fe19551c1486af1e170-golang-arm64
ghcr.io/openhands/agent-server:openhands-comments-policy-agents-md-golang-arm64
ghcr.io/openhands/agent-server:83dbe2b-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:83dbe2b-java-amd64
ghcr.io/openhands/agent-server:83dbe2bb6b39eab11a921fe19551c1486af1e170-java-amd64
ghcr.io/openhands/agent-server:openhands-comments-policy-agents-md-java-amd64
ghcr.io/openhands/agent-server:83dbe2b-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:83dbe2b-java-arm64
ghcr.io/openhands/agent-server:83dbe2bb6b39eab11a921fe19551c1486af1e170-java-arm64
ghcr.io/openhands/agent-server:openhands-comments-policy-agents-md-java-arm64
ghcr.io/openhands/agent-server:83dbe2b-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:83dbe2b-python-amd64
ghcr.io/openhands/agent-server:83dbe2bb6b39eab11a921fe19551c1486af1e170-python-amd64
ghcr.io/openhands/agent-server:openhands-comments-policy-agents-md-python-amd64
ghcr.io/openhands/agent-server:83dbe2b-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-amd64
ghcr.io/openhands/agent-server:83dbe2b-python-arm64
ghcr.io/openhands/agent-server:83dbe2bb6b39eab11a921fe19551c1486af1e170-python-arm64
ghcr.io/openhands/agent-server:openhands-comments-policy-agents-md-python-arm64
ghcr.io/openhands/agent-server:83dbe2b-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-arm64
ghcr.io/openhands/agent-server:83dbe2b-golang
ghcr.io/openhands/agent-server:83dbe2bb6b39eab11a921fe19551c1486af1e170-golang
ghcr.io/openhands/agent-server:openhands-comments-policy-agents-md-golang
ghcr.io/openhands/agent-server:83dbe2b-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:83dbe2b-java
ghcr.io/openhands/agent-server:83dbe2bb6b39eab11a921fe19551c1486af1e170-java
ghcr.io/openhands/agent-server:openhands-comments-policy-agents-md-java
ghcr.io/openhands/agent-server:83dbe2b-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:83dbe2b-python
ghcr.io/openhands/agent-server:83dbe2bb6b39eab11a921fe19551c1486af1e170-python
ghcr.io/openhands/agent-server:openhands-comments-policy-agents-md-python
ghcr.io/openhands/agent-server:83dbe2b-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim

About Multi-Architecture Support

  • Each variant tag (e.g., 83dbe2b-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 83dbe2b-python-amd64) are also available if needed

Adds guidance to keep PR-style narration and diff summaries out of
source comments, reserving comments for genuinely unintuitive context
the reader cannot infer from the code itself.

Closes #3498

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Python API breakage checks — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@juanmichelini juanmichelini changed the title docs(agents): add explicit comments policy to AGENTS.md &lt;CODE&gt; section docs(agents): add explicit comments policy to AGENTS.md Jun 4, 2026
@juanmichelini
juanmichelini marked this pull request as ready for review June 4, 2026 04:36

all-hands-bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Review complete.

This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here.

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

PR Review: Add comments policy to AGENTS.md

Summary

This PR adds an explicit Comments policy bullet (with four sub-bullets) to the <CODE> section of AGENTS.md, in response to issue #3498. The change is straightforward and addresses the core request directly.

What's good

  • Addresses the issue directly: The new policy logically covers all four scenarios flagged in #3498 — restating code, narrating diffs, describing non-local behavior, and the ratio test (3-line change → 19 lines of comments).
  • Consistent style: The bullet format and voice match the surrounding <CODE> section guidelines.
  • Tone and clarity: The language is direct, actionable, and appropriately prescriptive.
  • Documentation-only change: Correctly categorized as Docs / chore, no tests needed per the contributor checklist.

Minor style suggestion

The main bullet opens with:

Comments policy: write comments sparingly and strategically...

The other bullets in this section do not have an opening narrative line — they jump straight into the sub-bullets. For consistency, consider whether the main bullet should just be the heading and sub-bullets (no sentence following it). Either approach is fine; just ensuring the PR author is intentional about the deviation.

Verdict

Approve. The change is well-scoped, clearly motivated, and the policy content is sound. No further changes required.


This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

✅ QA Report: PASS

The docs-only change was verified by setting up the repo and rendering the affected AGENTS.md guidance before/after; the new comments policy is visible only on the PR head and matches the stated issue.

Does this PR achieve its stated goal?

Yes. The stated goal was to add an explicit comments policy to the root AGENTS.md <CODE> section addressing verbose, redundant, non-local code comments. Baseline rendering of origin/main did not contain the policy terms, while the PR head rendered with Comments policy, genuinely unintuitive, and the 3-line change should not produce 19 lines guidance present.

Phase Result
Environment Setup ✅ make build completed successfully; no tests/linters were run locally.
CI Status ⏳ Observed 33 successful, 2 skipped, 1 pending (QA Changes by OpenHands) via gh pr checks.
Functional Verification ✅ Before/after doc rendering confirmed the policy is added and visible.
Functional Verification

Test 1: Before/after guidance presence in the rendered CODE section

Step 1 — Reproduce / establish baseline without the fix:
Ran a script that extracted AGENTS.md from origin/main, rendered the <CODE> section with markdown-it-py, and checked for the policy phrases:

--- base main ---
CODE section chars: 1331
Markdown rendered HTML chars: 1330
'Comments policy': False
'restate what the code already says': False
'summarize the surrounding diff/PR': False
'non-local parts of the system': False
'genuinely unintuitive': False
'3-line change should not produce 19 lines': False

This establishes the baseline: the root contributor guidance did not yet include the explicit comments policy requested by issue #3498.

Step 2 — Apply the PR's changes:
The local checkout was already on PR head 83dbe2bb6b39eab11a921fe19551c1486af1e170 (openhands/comments-policy-agents-md).

Step 3 — Re-run with the fix in place:
The same script against HEAD:AGENTS.md produced:

--- PR head ---
CODE section chars: 2505
Markdown rendered HTML chars: 2504
'Comments policy': True
'restate what the code already says': True
'summarize the surrounding diff/PR': True
'non-local parts of the system': True
'genuinely unintuitive': True
'3-line change should not produce 19 lines': True

This confirms the PR adds the policy in the intended section and covers the concrete issue themes: redundant comments, PR/blame context, non-local drift, genuinely unintuitive cases, and the 3-line/19-line example.

Test 2: GitHub-rendered Markdown visibility

Step 1 — Reproduce / establish baseline without the fix:
Rendered the base <CODE> section through GitHub's Markdown API:

--- base main GitHub-rendered CODE section ---
GitHub HTML chars: 1356
'Comments policy' visible in rendered output: False
'genuinely unintuitive' visible in rendered output: False
'3-line change should not produce 19 lines' visible in rendered output: False

This confirms a GitHub reader of the base documentation would not see the new policy.

Step 2 — Apply the PR's changes:
Used the same GitHub Markdown API workflow against the PR head content.

Step 3 — Re-run with the fix in place:

--- PR head GitHub-rendered CODE section ---
GitHub HTML chars: 2530
'Comments policy' visible in rendered output: True
'genuinely unintuitive' visible in rendered output: True
'3-line change should not produce 19 lines' visible in rendered output: True

This confirms the new guidance is visible in rendered documentation, which is the user-facing behavior for this docs-only PR.

Issues Found

None.


This QA review was created by an AI agent (OpenHands) on behalf of the requester.

@juanmichelini
juanmichelini merged commit e253c5e into main Jun 4, 2026
41 of 42 checks passed
@juanmichelini
juanmichelini deleted the openhands/comments-policy-agents-md branch June 4, 2026 06:09
pengzhang-create pushed a commit to Pyromind-Dynamics/software-agent-sdk that referenced this pull request Aug 13, 2026
Co-authored-by: openhands <openhands@all-hands.dev>
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.

Very verbose comments on PRs

3 participants