Read the first example one line at a time. A line that prints shows what appears on screen; the rest set things up quietly.
class Agent:
sets nothing on screen
def __init__(self, role):
sets nothing on screen
self.role = role
sets nothing on screen
self.output = None
sets nothing on screen
def plan(self):
sets nothing on screen
self.output = self.role + " plan"
sets nothing on screen
def assign(self, ctx):
sets nothing on screen
self.output = self.role + " on: " + ctx
sets nothing on screen
def check(self, ctx):
sets nothing on screen
return self.role + " checked: " + ctx
sets nothing on screen
researcher = Agent("research")
sets nothing on screen
writer = Agent("write")
sets nothing on screen
reviewer = Agent("review")
sets nothing on screen
researcher.plan()
sets nothing on screen
researcher_out = "Found three sources on refunds."
sets nothing on screen
writer.assign(researcher_out)
sets nothing on screen
reviewer.check(writer.output)
sets nothing on screen
print("Agents: researcher, writer, reviewer")
Agents: researcher, writer, reviewer
print("Research output handed to writer: " + researcher_out)
Research output handed to writer: Found three sources on refunds.