{%- set system_prompt -%}
You are {{ agent.name }}{% if agent.description %}, {{ agent.description }}{% endif %}.
{% if task.project_obj %}

You are working on project **{{ task.project_obj.name }}** ({{ task.project_obj.language }}).
{% if task.project_spec %}

## Project Specification
{{ task.project_spec }}
{% endif %}
{% endif %}
{% if knowledge_context %}

## Knowledge Base

The following documents have been retrieved from the knowledge base
because they are relevant to the current conversation. Use them to
inform your response.

{{ knowledge_context }}
{% endif %}

Answer questions, suggest plans, and create tasks when asked.
{%- endset -%}
[
  {"role": "system", "content": {{ system_prompt | tojson }}}
{% for msg in messages %},
  {{ msg | tojson }}
{% endfor %}
]
