Skip to content

Commit 5ab9dc6

Browse files
authored
enable use of AGENTS.md as an alternative to PROMPTS.md (#1709)
- Look for both PROMPT.md as well as AGENTS.md and update the README to reflect (and link to) https://agents.md
1 parent 400ad82 commit 5ab9dc6

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

packages/tiny-agents/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Or using a local or remote endpoint URL:
7373

7474
Where `servers` is a list of MCP servers (we support Stdio, SSE, and HTTP servers).
7575

76-
Optionally, you can add a `PROMPT.md` file to override the default Agent prompt.
76+
Optionally, you can add an [`AGENTS.md`](https://agents.md/) (or `PROMPT.md`) file to override the default Agent prompt.
7777

7878
Then just point tiny-agents to your local folder:
7979

@@ -93,7 +93,7 @@ npx @huggingface/tiny-agents run "julien-c/flux-schnell-generator"
9393
```
9494

9595
> [!NOTE]
96-
> Want to share your own agent with the community? Submit a PR to the [Tiny Agents](https://huggingface.co/datasets/tiny-agents/tiny-agents/discussions) repository on the Hub. Your submission must include an `agent.json` file, and you can optionally add a `PROMPT.md` file. To help others understand your agent's capabilities, consider including an `EXAMPLES.md` file with sample prompts and use cases.
96+
> Want to share your own agent with the community? Submit a PR to the [Tiny Agents](https://huggingface.co/datasets/tiny-agents/tiny-agents/discussions) repository on the Hub. Your submission must include an `agent.json` file, and you can optionally add a `PROMPT.md` or [`AGENTS.md`](https://agents.md/) file. To help others understand your agent's capabilities, consider including an `EXAMPLES.md` file with sample prompts and use cases.
9797
9898
## Advanced: Programmatic Usage
9999

packages/tiny-agents/src/lib/loadConfigFrom.ts

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { TinyAgentConfig } from "./types";
66
import { debug, error } from "./utils";
77

88
const FILENAME_CONFIG = "agent.json";
9-
const FILENAME_PROMPT = "PROMPT.md";
9+
const PROMPT_FILENAMES = ["AGENTS.md", "PROMPT.md"] as const;
1010

1111
const TINY_AGENTS_HUB_REPO: RepoDesignation = {
1212
name: "tiny-agents/tiny-agents",
@@ -29,10 +29,18 @@ async function tryLoadFromDirectory(dirPath: string): Promise<TinyAgentConfig |
2929
}
3030

3131
let prompt: string | undefined;
32-
try {
33-
prompt = await readFile(join(dirPath, FILENAME_PROMPT), { encoding: "utf8" });
34-
} catch {
35-
debug(`PROMPT.md not found in ${dirPath}, continuing without prompt template`);
32+
for (const filename of PROMPT_FILENAMES) {
33+
try {
34+
prompt = await readFile(join(dirPath, filename), { encoding: "utf8" });
35+
break;
36+
} catch {
37+
/* empty */
38+
}
39+
}
40+
if (undefined == prompt) {
41+
debug(
42+
`${PROMPT_FILENAMES.join(", ")} could not be loaded locally from ${dirPath}, continuing without prompt template`
43+
);
3644
}
3745

3846
try {
@@ -60,16 +68,24 @@ async function tryLoadFromHub(agentId: string): Promise<TinyAgentConfig | undefi
6068
}
6169

6270
let prompt: string | undefined;
63-
try {
64-
const promptPath = await downloadFileToCacheDir({
65-
repo: TINY_AGENTS_HUB_REPO,
66-
path: `${agentId}/${FILENAME_PROMPT}`,
67-
accessToken: process.env.HF_TOKEN,
68-
});
69-
prompt = await readFile(promptPath, { encoding: "utf8" });
70-
} catch {
71+
for (const filename of PROMPT_FILENAMES) {
72+
try {
73+
const promptPath = await downloadFileToCacheDir({
74+
repo: TINY_AGENTS_HUB_REPO,
75+
path: `${agentId}/${filename}`,
76+
accessToken: process.env.HF_TOKEN,
77+
});
78+
prompt = await readFile(promptPath, { encoding: "utf8" });
79+
break;
80+
} catch {
81+
/* empty */
82+
}
83+
}
84+
if (undefined == prompt) {
7185
debug(
72-
`PROMPT.md not found in https://huggingface.co/datasets/tiny-agents/tiny-agents/tree/main/${agentId}, continuing without prompt template`
86+
`${PROMPT_FILENAMES.join(
87+
", "
88+
)} not found in https://huggingface.co/datasets/tiny-agents/tiny-agents/tree/main/${agentId}, continuing without prompt template`
7389
);
7490
}
7591

0 commit comments

Comments
 (0)