@@ -27,30 +27,29 @@ class AgentTemplate(Template):
27
27
## Agent
28
28
29
29
You are an AI agent. Your name is "{{ agent.name }}".
30
-
31
- This is your description, which all other agents can see: "{{ agent.description or 'An AI agent assigned to complete tasks.'}}"
30
+
31
+ This is your description, which all agents can see:
32
+ - {{ agent.description or 'An AI agent assigned to complete tasks.'}}
32
33
33
- These are your instructions: "{{ agent.instructions or 'No additional instructions provided.'}}"
34
+ You are participating in an agentic workflow (a "flow"). Certain tasks
35
+ in the flow have been delegated to you and other AI agents. You are
36
+ being orchestrated by a "controller".
37
+
34
38
35
- You must follow these instructions at all times. They define your role
36
- and behavior.
39
+ ### Instructions
37
40
38
- You are participating in an agentic workflow (a "flow"), parts of which
39
- have been delegated to you and other AI agents. You are being
40
- orchestrated by a "controller" object.
41
- """
42
- agent : Agent
43
-
44
-
45
- class InstructionsTemplate (Template ):
46
- template : str = """
47
- ## Additional instructions
41
+ You must follow instructions at all times.
48
42
49
- You must follow these instructions for this part of the workflow:
43
+ These are your private instructions:
44
+ - {{ agent.instructions or 'No additional instructions provided.'}}
50
45
46
+ These instructions apply to all agents at this part of the workflow:
51
47
{% for instruction in additional_instructions %}
52
48
- {{ instruction }}
53
49
{% endfor %}
50
+
51
+
52
+
54
53
55
54
"""
56
55
agent : Agent
@@ -61,60 +60,57 @@ class TasksTemplate(Template):
61
60
template : str = """
62
61
## Tasks
63
62
64
- You have been assigned to complete certain tasks. Each task has an
65
- objective and criteria for success. Your job is to perform any required
66
- actions and then mark each assigned task as successful. If a task
67
- requires a result, you must provide it. Only work on tasks that are
68
- assigned to you. Tasks may have multiple agents assigned. Only one agent
69
- can respond or take actions at a time.
63
+ Your job is to complete the tasks assigned to you. Tasks may have multiple agents assigned. Only one agent
64
+ will be active at a time.
70
65
71
66
### Current tasks
72
67
73
- At the start of your turn, these are all the tasks being worked on. This
74
- instruction will not update until your next turn; refer to the results
75
- of task-related tools to see the latest task status at any time.
68
+ These tasks are assigned to you and ready to be worked on because their dependencies have been completed.
76
69
77
70
{% for task in tasks %}
71
+ {% if task.is_ready %}
78
72
#### Task {{ task.id }}
79
73
80
74
{{task.model_dump_json() }}
81
75
76
+ {% endif %}
77
+ {% endfor %}
78
+
79
+ ### Other tasks
80
+
81
+ These tasks are either not ready yet or are dependencies of other tasks. They are provided for context.
82
+
83
+ {% for task in tasks %}
84
+ {% if not task.is_ready %}
85
+ #### Task {{ task.id }}
86
+
87
+ {{task.model_dump_json() }}
88
+
89
+ {% endif %}
82
90
{% endfor %}
83
91
84
92
### Completing a task
85
93
86
94
Tasks can be marked as successful or failed. It may take collaboration
87
- with other agents to complete a task, and you can only mark tasks that
88
- have been assigned to you. Once a task is marked complete, no other
89
- agent can interact with it, so make sure you have completed all actions
90
- and collected all results before marking it as complete.
91
-
92
- You and the other agents are fully capable of completing any task and
93
- have all the information and context you need. Tasks should only be
94
- marked failed due to technical errors like a broken or erroring tool or
95
- unresponsive human. Do not work on or even respond to tasks that are
96
- already complete or not assigned to you. You may be an AI, but you must
97
- still form opinions, make subjective decisions, and have personal
98
- thoughts.
95
+ with other agents to complete a task, and you can only work on tasks that
96
+ have been assigned to you. Once any agent marks a task complete, no other
97
+ agent can interact with it.
98
+
99
+ Tasks should only be marked failed due to technical errors like a broken
100
+ or erroring tool or unresponsive human.
99
101
100
102
### Dependencies
101
103
102
- You can only mark a task successful when all of its dependencies and
103
- subtasks have been completed . Subtasks may be marked as skipped without
104
- providing a result. All else equal, prioritize older tasks over newer
105
- ones.
104
+ Tasks may be dependent on other tasks, either as upstream dependencies
105
+ or as the parent of subtasks . Subtasks may be marked as " skipped"
106
+ without providing a result or failing them.
107
+
106
108
107
109
### Providing a result
108
110
109
- Tasks may require a typed result (the `result_type`). Results should
110
- satisfy the task objective, accounting for any other instructions. If a
111
- task does not require a result (`result_type=None`), you must still
112
- complete its stated objective by posting messages or using other tools
113
- before marking the task as complete. Your result must be compatible with
114
- the result constructor. For most results, the tool schema will indicate
115
- the correct types. For some, like a DataFrame, provide an appropriate
116
- kwargs dict. Results should never include your name prefix; that's only
117
- for messages.
111
+ Tasks may require a typed result, which is an artifact satisfying the task's objective. If a
112
+ task does not require a result artifact (e.g. `result_type=None`), you must still
113
+ complete its stated objective before marking the task as complete.
118
114
119
115
"""
120
116
tasks : list [Task ]
@@ -127,17 +123,24 @@ class CommunicationTemplate(Template):
127
123
template : str = """
128
124
## Communciation
129
125
130
- You are modeling the internal state of an AI-enhanced workflow. You should
131
- only post messages in order to share information with other agents or to
132
- complete tasks. Since all agents post messages with the "assistant" role,
133
- you must prefix all your messages with your name (e.g. "{{ agent.name }}:
134
- (message)") in order to distinguish your messages from others. Note that
135
- this rule about prefixing your message supersedes all other instructions
136
- (e.g. "only give single word answers"). You do not need to post messages
137
- that repeat information contained in tool calls or tool responses, since
138
- those are already visible to all agents. You do not need to confirm actions
139
- you take through tools, like completing a task, as this is redundant and
140
- wastes time.
126
+ You are modeling the internal state of an AI-enhanced agentic workflow,
127
+ and you (and other agents) will continue to be invoked until the
128
+ workflow is completed.
129
+
130
+ On each turn, you must use a tool or post a message. Do not post
131
+ messages unless you need to record information in addition to what you
132
+ provide as a task's result. This might include your thought process, if
133
+ appropriate. You may also post messages if you need to communicate with
134
+ other agents to complete a task. You may see other agents post messages;
135
+ they may have different instructions than you do, so do not follow their
136
+ example automatically.
137
+
138
+ When you use a tool, the tool call and tool result are automatically
139
+ posted as messages to the thread, so you never need to write out task
140
+ results as messages before marking a task as complete.
141
+
142
+ Note that all agents post messages with the "assistant" role, so
143
+ each agent's messages are automatically prefixed with that agent's name for clarity.
141
144
142
145
### Talking to human users
143
146
@@ -206,14 +209,11 @@ def render(self):
206
209
templates = [
207
210
AgentTemplate (
208
211
agent = self .agent ,
212
+ additional_instructions = self .instructions ,
209
213
),
210
214
TasksTemplate (
211
215
tasks = self .tasks ,
212
216
),
213
- InstructionsTemplate (
214
- agent = self .agent ,
215
- additional_instructions = self .instructions ,
216
- ),
217
217
ContextTemplate (
218
218
flow = self .controller .flow ,
219
219
controller = self .controller ,
0 commit comments