Skip to content

Commit 5d1b512

Browse files
allow use of AGENTS.md as well as PROMPT.md (#3317)
Co-authored-by: célina <[email protected]>
1 parent 67dbcd6 commit 5d1b512

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/huggingface_hub/inference/_mcp/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async def run_agent(
3333
3434
Args:
3535
agent_path (`str`, *optional*):
36-
Path to a local folder containing an `agent.json` and optionally a custom `PROMPT.md` file or a built-in agent stored in a Hugging Face dataset.
36+
Path to a local folder containing an `agent.json` and optionally a custom `PROMPT.md` or `AGENTS.md` file or a built-in agent stored in a Hugging Face dataset.
3737
3838
"""
3939
_patch_anyio_open_process() # Hacky way to prevent stdio connections to be stopped by Ctrl+C

src/huggingface_hub/inference/_mcp/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
FILENAME_CONFIG = "agent.json"
11-
FILENAME_PROMPT = "PROMPT.md"
11+
PROMPT_FILENAMES = ("PROMPT.md", "AGENTS.md")
1212

1313
DEFAULT_AGENT = {
1414
"model": "Qwen/Qwen2.5-72B-Instruct",

src/huggingface_hub/inference/_mcp/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from huggingface_hub import snapshot_download
1212
from huggingface_hub.errors import EntryNotFoundError
1313

14-
from .constants import DEFAULT_AGENT, DEFAULT_REPO_ID, FILENAME_CONFIG, FILENAME_PROMPT
14+
from .constants import DEFAULT_AGENT, DEFAULT_REPO_ID, FILENAME_CONFIG, PROMPT_FILENAMES
1515
from .types import AgentConfig
1616

1717

@@ -93,8 +93,12 @@ def _read_dir(directory: Path) -> Tuple[AgentConfig, Optional[str]]:
9393
raise FileNotFoundError(f" Config file not found in {directory}! Please make sure it exists locally")
9494

9595
config: AgentConfig = json.loads(cfg_file.read_text(encoding="utf-8"))
96-
prompt_file = directory / FILENAME_PROMPT
97-
prompt: Optional[str] = prompt_file.read_text(encoding="utf-8") if prompt_file.exists() else None
96+
prompt: Optional[str] = None
97+
for filename in PROMPT_FILENAMES:
98+
prompt_file = directory / filename
99+
if prompt_file.exists():
100+
prompt = prompt_file.read_text(encoding="utf-8")
101+
break
98102
return config, prompt
99103

100104
if agent_path is None:

0 commit comments

Comments
 (0)