Skip to content

Load model-specific repo instructions (CLAUDE.md for Claude only, GEMINI.md for Gemini only) - #1328

Merged
enyst merged 8 commits into
mainfrom
openhands/model-specific-repo-instructions-1282
Dec 28, 2025
Merged

enyst merged 8 commits into
mainfrom
openhands/model-specific-repo-instructions-1282

Conversation

@enyst

@enyst enyst commented Dec 4, 2025 •

Copy link
Copy Markdown
Member

Summary

  • Implement model-specific repository instruction loading:
    • CLAUDE.md is included only when using Anthropic/Claude models
    • GEMINI.md is included only when using Gemini models.

Motivation
This change addresses issue #1282 by ensuring provider-specific instruction files are applied only for the relevant model family. This avoids cross-provider bleed of rules and aligns behavior with prior discussions and PR #1280.

Design notes

  • Filtering is done at render time (AgentContext) to keep Skill loading simple and preserve existing patterns.
  • Detection is provider-name based and considers both model and model_canonical_name for proxy scenarios.
  • Backward compatibility maintained: if model is not provided, behavior is unchanged.

Testing

  • Added new tests: tests/sdk/context/test_agent_context_model_specific.py
  • Ran the full AgentContext tests to ensure no regressions: all pass locally.

Closes #1282

Co-authored-by: openhands openhands@all-hands.dev

@enyst 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.12-nodejs22 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:a1c1879-python

Run

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

All tags pushed for this build

ghcr.io/openhands/agent-server:a1c1879-golang-amd64
ghcr.io/openhands/agent-server:a1c1879-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:a1c1879-golang-arm64
ghcr.io/openhands/agent-server:a1c1879-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:a1c1879-java-amd64
ghcr.io/openhands/agent-server:a1c1879-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:a1c1879-java-arm64
ghcr.io/openhands/agent-server:a1c1879-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:a1c1879-python-amd64
ghcr.io/openhands/agent-server:a1c1879-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-amd64
ghcr.io/openhands/agent-server:a1c1879-python-arm64
ghcr.io/openhands/agent-server:a1c1879-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-arm64
ghcr.io/openhands/agent-server:a1c1879-golang
ghcr.io/openhands/agent-server:a1c1879-java
ghcr.io/openhands/agent-server:a1c1879-python

About Multi-Architecture Support

  • Each variant tag (e.g., a1c1879-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., a1c1879-python-amd64) are also available if needed

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

github-actions Bot commented Dec 4, 2025 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/agent
   base.py1761989%165, 171, 190, 239–240, 251–253, 266, 274–275, 309, 356, 363, 376, 413–414, 424–425
openhands-sdk/openhands/sdk/context
   agent_context.py1164660%87, 92, 102–103, 105–108, 110, 114–115, 117, 124–125, 127–130, 132, 136–138, 150–156, 184, 188, 204–206, 221, 229–231, 235, 238, 243, 251, 256–258, 263
openhands-sdk/openhands/sdk/context/skills
   skill.py27421122%121–127, 133–137, 150, 153, 157, 169–170, 175, 182, 198, 201–202, 204, 208, 211–213, 216–218, 220–222, 225, 228, 232, 235, 243, 248–250, 256, 258–264, 267, 276–277, 286–289, 302–309, 319–320, 322, 328–329, 331, 340–343, 345–348, 356–358, 366–368, 386–387, 389–390, 393, 396–397, 400–404, 407–409, 412–414, 418–419, 422–423, 425–427, 429–430, 432, 436, 457–458, 460–463, 465–467, 470–474, 476, 480–481, 483, 486, 504–505, 507–508, 511, 516–518, 521, 523–525, 528–532, 534, 539–540, 544, 547, 561–563, 581, 583–587, 594, 601–605, 610–612, 614, 629, 631, 633–637, 640–643, 677, 679, 681–682, 684–686, 689–692, 695, 697, 700–702, 706–712, 714–715, 717, 720
TOTAL14132657853% 

@enyst
enyst marked this pull request as draft December 4, 2025 22:02
enyst and others added 2 commits December 4, 2025 22:14
…/Anthropic, GEMINI.md only for Gemini. Add Skill.should_include_for_model; plumb through load/load_skills_from_dir; update tests to assert gating at loader.

This aligns filtering with the loader that discovers third-party files.

Co-authored-by: openhands <openhands@all-hands.dev>
…e loader signature; gate vendor files in loader; run format.

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

Copy link
Copy Markdown
Contributor

[Automatic Post]: It has been a while since there was any activity on this PR. @enyst, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up.

@openhands-ai

openhands-ai Bot commented Dec 20, 2025

Copy link
Copy Markdown

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • Agent Server

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #1328 at branch `openhands/model-specific-repo-instructions-1282`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

@enyst

enyst commented Dec 20, 2025

Copy link
Copy Markdown
Member Author

@OpenHands Look at the SDK codebase, find how we load system prompt pieces per LLM. That problem is similar to this: loading Skills per (some) LLMs.

Verify how we can do this, so that the code is clean and inline with the existing implementation. Could we do something similar to that, rather than adding a different way to implement a similar thing?
/codereview-roasted

@openhands-ai

openhands-ai Bot commented Dec 20, 2025

Copy link
Copy Markdown

I'm on it! enyst can track my progress at all-hands.dev

@openhands-ai

openhands-ai Bot commented Dec 20, 2025

Copy link
Copy Markdown

Summary of findings and recommendation

What you asked
You asked how we currently load system-prompt pieces per LLM and whether we can apply the same pattern to loading Skills for specific LLMs, instead of introducing a different mechanism.

What the code does today (system prompt)

  • AgentBase.system_message computes model_family/model_variant using get_model_prompt_spec(self.llm.model, self.llm.model_canonical_name).
  • system_prompt.j2 conditionally includes model-specific snippets (model_specific/{family}.j2 and model_specific/{family}/{variant}.j2).
  • This is a centralized, render-time decision: clean, simple, and model-aware where the LLM is available.

What the current branch does for Skills

  • Vendor-specific repo Skills (e.g., claude.md, gemini.md) are filtered in load_skills_from_dir via llm_model/llm_model_canonical with ad-hoc string checks (Skill.should_include_for_model).
  • AgentContext.get_system_message_suffix doesn’t receive model info.
  • load_user_skills/load_project_skills don’t forward model info, so vendor gating won’t occur in those common code paths unless the caller explicitly passes llm_model to load_skills_from_dir.
  • This diverges from the system-prompt approach and is easy to miss.

Recommendation: mirror the system-prompt pattern

  • Keep Skill loading model-agnostic. Do NOT gate inside the loader.
  • Gate vendor-specific repo Skills at render time inside AgentContext.get_system_message_suffix:
    • Pass model info (or model_family/model_variant) from AgentBase.system_message to AgentContext, reusing get_model_prompt_spec as the single source of truth.
    • Filter “claude” only for Anthropic/Claude family, “gemini” only for Gemini family; otherwise include all (backward compatibility when model info absent).
  • This keeps logic consistent, centralized, and avoids pushing model-awareness into every loader call.

Testing implications

  • Prefer end-to-end tests at the AgentContext/system-message level:
    • With repo.md + claude.md + gemini.md, verify only the matching vendor file is included when family is Claude/Gemini.
    • When no model info is provided, verify all vendor files are included (backward compatibility).
  • If loader-gating remains temporarily, add integration tests that go through AgentBase.system_message so we don’t rely on direct calls to load_skills_from_dir with llm params.

Bottom line
Yes—we can and should do this similar to system-prompt loading: determine model_family once, and gate vendor-specific repo Skills at render time in AgentContext. This aligns with the existing system-prompt design, reduces special cases, and preserves backward compatibility.

View full conversation

- Gate CLAUDE.md/GEMINI.md at render-time in AgentContext using get_model_prompt_spec
- Pass llm model identifiers from AgentBase into AgentContext.get_system_message_suffix
- Remove loader-level gating and llm params from load_skills_from_dir
- Update/replace tests to validate gating at AgentContext/system-message level

Co-authored-by: openhands <openhands@all-hands.dev>
@enyst
enyst marked this pull request as ready for review December 20, 2025 06:34
@blacksmith-sh

blacksmith-sh Bot commented Dec 27, 2025

Copy link
Copy Markdown
Contributor

[Automatic Post]: It has been a while since there was any activity on this PR. @enyst, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up.

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

LGTM, thanks!

@enyst

enyst commented Dec 28, 2025

Copy link
Copy Markdown
Member Author

@neubig On a side note, this was ready for review last week, I think the workflow was supposed to try to assign a reviewer 🤔

image

But I think maybe we can think this over a bit.

@enyst
enyst merged commit 4eb0aa0 into main Dec 28, 2025
@enyst
enyst deleted the openhands/model-specific-repo-instructions-1282 branch December 28, 2025 06:12
StressTestor pushed a commit to StressTestor/software-agent-sdk that referenced this pull request Jun 1, 2026
…INI.md for Gemini only) (OpenHands#1328)

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.

Model-specific repo instructions

2 participants