Configure agent instructions with files, templates, and dynamic context.
System prompts define what your agent knows and how it behaves. AFK supports three methods — inline strings, instruction files, and auto-detection — with Jinja2 templating for dynamic values.
You are a financial analyst specializing in tech companies.## Guidelines- Use data-driven analysis- Cite specific metrics when available- Present both bull and bear cases- Keep responses under 500 words
AFK automatically looks for an instruction file based on the agent’s name:
When multiple sources are available, AFK uses this order:The first non-empty source wins. If you set both instructions and instruction_file, the inline string takes priority.
Use {{ variable }} syntax to inject dynamic values into prompts:
agent = Agent( name="support-agent", model="gpt-5.2-mini", instructions=""" You are a support agent for {{ company_name }}. Today's date is {{ current_date }}. The customer's plan is {{ plan_tier }}. {% if plan_tier == "enterprise" %} You may offer extended SLAs and priority escalation. {% else %} Refer complex issues to the support team. {% endif %} """, context={ "company_name": "Acme Corp", "current_date": "2025-01-15", "plan_tier": "enterprise", },)
You are a {{ language }} code reviewer following {{ style_guide }}.## Rules- Report at most {{ max_issues }} issues per review- Classify issues as: error, warning, style- Suggest a fix for each issue- Be constructive and specific
Check the file path. Make sure it’s relative to the working directory or absolute.
PromptTemplateError
Jinja2 template syntax error
Check for unclosed {{ }} or {% %} blocks.
PromptTemplateError
Missing template variable
Add the variable to Agent.context or provide a default: {{ var | default("fallback") }}
Keep prompts in version control. Store instruction files in a prompts/
directory and track changes in git. This gives you prompt history, diffs, and
the ability to A/B test prompt versions.