Use prompts in agents
Add a published prompt to an agent so that it is used as the agent’s instruction at runtime.
Before you begin
- Follow the Get started guide to set up agentregistry and start the agentregistry daemon.
- Create an agent, such as with the
arctl agent initcommand. - Publish a prompt in agentregistry.
Add a prompt to an agent
-
Navigate to your agent project directory.
cd my-agent -
Add a prompt reference to the agent manifest (
agent.yaml). The--registry-prompt-nameflag specifies the prompt name that you used when you published the skill in agentregistry. The following command adds apromptssection to youragent.yamlfile.arctl agent add-prompt reviewer --registry-prompt-name code-reviewExample output:
✓ Added prompt 'reviewer' to agent.yamlExample
promptssection in theagent.yamlfile:prompts: - name: reviewer registryURL: http://localhost:12121 registryPromptName: code-reviewYou can pin a specific version by using the--registry-prompt-versionflag. If omitted, the latest version is resolved at runtime. -
To use a prompt from a different registry, use the
--registry-urlflag.arctl agent add-prompt reviewer --registry-prompt-name code-review --registry-url https://registry.example.com
How prompts are resolved at runtime
When you run the agent with arctl agent run, the following happens automatically:
- The CLI reads the
promptssection from theagent.yamlfile. - For each prompt reference, the CLI fetches the prompt content from the registry’s REST API.
- The resolved prompt content is written to a
prompts.jsonfile in the agent’s config directory. - The agent’s
prompts_loader.py(autogenerated) reads theprompts.jsonfile at startup. - The
build_instruction()function returns the resolved prompt content as the agent’s instruction, replacing the default instruction.
arctl agent run .If no prompts are resolved (for example, the registry is unreachable or no prompts are configured), the agent falls back to the default instruction defined in the
agent.py file.