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
Make sure that you have:
- A running agentregistry instance
- A published prompt in the registry (see Create and publish prompts)
- An agent project created with
arctl agent init
Add a prompt to an agent
-
Navigate to your agent project directory.
cd my-agent -
Add a prompt reference to the agent manifest. The
--registry-prompt-nameflag specifies the prompt name as published in the registry.arctl agent add-prompt reviewer --registry-prompt-name code-reviewExample output:
✓ Added prompt 'reviewer' to agent.yamlThis adds a
promptssection to youragent.yaml: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 fromagent.yaml. - 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) readsprompts.jsonat 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
agent.py.