Skip to content

Commit 84d0fde

Browse files
committed
Add live printhandler by default
1 parent 4bcc636 commit 84d0fde

File tree

7 files changed

+400
-296
lines changed

7 files changed

+400
-296
lines changed

src/controlflow/core/controller/controller.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,21 @@ async def _run_agent(self, agent: Agent, tasks: list[Task]):
135135
system_message = SystemMessage(content=instructions)
136136
messages = self.history.load_messages(thread_id=self.flow.thread_id)
137137

138+
# setup handler
139+
if controlflow.settings.enable_tui:
140+
handlers = [TUIHandler()]
141+
elif controlflow.settings.enable_print_handler:
142+
handlers = [PrintHandler()]
143+
else:
144+
handlers = []
145+
138146
# call llm
139147
response_messages = []
140148
async for msg in await completion_async(
141149
messages=[system_message] + messages,
142150
model=agent.model,
143151
tools=tools,
144-
handlers=[TUIHandler()]
145-
if controlflow.settings.enable_tui
146-
else [PrintHandler()],
152+
handlers=handlers,
147153
max_iterations=1,
148154
stream=True,
149155
message_preprocessor=add_agent_name_to_message,

src/controlflow/core/controller/instruction_template.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,15 @@ class CommunicationTemplate(Template):
129129
130130
On each turn, you must use a tool or post a message. Do not post
131131
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.
132+
provide as a task's result, or for the following reasons:
133+
134+
- You need to post a message or otherwise communicate to complete a task.
135+
- You need to communicate with other agents to complete a task.
136+
- You want to write your thought process for future reference.
137+
138+
Note that You may see other agents post messages; they may have
139+
different instructions than you do, so do not follow their example
140+
automatically.
137141
138142
When you use a tool, the tool call and tool result are automatically
139143
posted as messages to the thread, so you never need to write out task

0 commit comments

Comments
 (0)