Test Drive: controlflow
Published on .
Today I’m test driving ControlFlow, “a Python framework for building agentic AI workflows.” I thought I’d take a document and turn it into a NotebookLM-deep-dive-style podcast script. The process was:
- Install controlflow
- Do the Seinfield converstaion example
- Update the example to do the deepdive
Well… I didn’t make much progress and I’ll explain below. I put my code below, which does technically produce some output, just not what I hoped and often with errors. My accomplishment of the day was turning on debug logging and also tracing with this code:
from langtrace_python_sdk import langtrace
langtrace.init(**config)
import openai
import logging
logging.getLogger("controlflow").setLevel(logging.DEBUG)
logging.getLogger("openai").setLevel(logging.DEBUG)
Code language: Python (python)
That was helpful, but still not enough.
"""toy attempt to clone of NotebookLM deep dive"""
import textwrap
import controlflow as cf
bill = cf.Agent(
name="Bill",
model="openai/gpt-4o-mini",
description="Charismatic podcast host",
instructions="""
You excel at finding interesting things in the text,
referring to those things and engaging your co-host,
to create an entertaining podcast.
Your objective is to say sentences that your co-host can react to.
""",
)
hillary = cf.Agent(
name="Hillary",
model="openai/gpt-4o-mini",
description="Funny podcast sidekick.",
instructions="""
You react to what your cost host says, often by asking a question.
Your objective is to react to what your co-host says.
""",
)
@cf.flow
def deepdive(text: str):
task = cf.Task(
"Deep dive a text",
agents=[bill, hillary],
completion_agents=[bill],
# result_type=None,
context=dict(text=text),
instructions=textwrap.dedent("""\
only one agent per turn. Keep responses to 1 sentence max.
react to what the other agent says.
bill references interesting passages from the text
Start with an introduction.
Probe the topics in the text
Finish with a brief outro.""")
)
task.run()
if __name__ == "__main__":
with open('transcript.txt', 'r') as file:
text = file.read()
deepdive(text=text[:5000])
Code language: Python (python)
╭─ Agent: Bill ────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Welcome to today's deep dive! We're diving into a fascinating oral history from East Boston, │
│ specifically reflecting on how the neighborhood has changed since 1906. What do you think │
│ about the transformation from coal yards to modern developments? │
│ │
╰──────────────────────────────────────────────────────────────────────────────────── 4:12:22 PM ─╯
╭─ Agent: Bill ────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ ✅ Tool call: "delegate_to_agent" │
│ │
│ Tool args: {'agent_id': '1837267a'} │
│ │
│ Tool result: Delegated to agent Hillary with ID 1837267a │
│ │
╰──────────────────────────────────────────────────────────────────────────────────── 4:12:23 PM ─╯
╭─ Agent: Hillary ─────────────────────────────────────────────────────────────────────────────────╮
│ │
│ ✅ Tool call: "delegate_to_agent" │
│ │
│ Tool args: {'agent_id': '1837267a'} │
│ │
│ Tool result: Delegated to agent Hillary with ID 1837267a │
│ │
╰──────────────────────────────────────────────────────────────────────────────────── 4:12:24 PM ─╯
╭─ Agent: Hillary ─────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Wow, it's wild to think about all that history! What do you think the community misses most │
│ about those coal yard days? │
│ │
╰──────────────────────────────────────────────────────────────────────────────────── 4:12:25 PM ─╯
╭─ Agent: Hillary ─────────────────────────────────────────────────────────────────────────────────╮
│ │
│ ✅ Tool call: "delegate_to_agent" │
│ │
│ Tool args: {'agent_id': '076eea10'} │
│ │
│ Tool result: Delegated to agent Bill with ID 076eea10 │
│ │
╰──────────────────────────────────────────────────────────────────────────────────── 4:12:25 PM ─╯
╭─ Agent: Bill ────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ ✅ Tool call: "delegate_to_agent" │
│ │
│ Tool args: {'agent_id': '076eea10'} │
│ │
│ Tool result: Delegated to agent Bill with ID 076eea10 │
│ │
╰──────────────────────────────────────────────────────────────────────────────────── 4:12:26 PM ─╯
╭─ Agent: Bill ────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ ✅ Tool call: "mark_task_a99578bf_successful" │
│ │
│ Tool args: {'result': 'The community likely misses the sense of camaraderie and shared │
│ culture that came from those days, as they relied on one another in a close-knit │
│ neighborhood.'} │
│ │
│ Tool result: Task #a99578bf ("Deep dive a text") marked successful. │
│ │
╰──────────────────────────────────────────────────────────────────────────────────── 4:12:27 PM ─
Code language: Python (python)