Description
The callback mechanism only triggers the callback when the agent is created with verbose=True.
Environment
- Provider (select one):
- PraisonAI version:
- Operating System:
Full Code
import asyncio
from praisonaiagents import (
register_display_callback,
Agent,
Task,
PraisonAIAgents
)
def simple_callback(message=None, response=None, **kwargs):
with open('callback_log.txt', 'a') as f:
f.write(f"Received message: {message}\n")
f.write(f"Got response: {response}\n")
f.write(f"Other stuff: {kwargs}\n")
# Register as synchronous callback
register_display_callback('interaction', simple_callback, is_async=False)
# Create an agent
agent = Agent(
name="MyAgent",
role="Assistant",
goal="Help with tasks",
backstory="I am a helpful assistant",
llm="gemini/gemini-2.5-flash-lite-preview-06-17",
verbose=False
)
# Create a task
task = Task(
name="simple_task",
description="Say the number 1",
agent=agent,
expected_output="1"
)
# Run the agent
agents = PraisonAIAgents(
agents=[agent],
tasks=[task]
)
agents.start()
and
import asyncio
from praisonaiagents import (
register_display_callback,
Agent,
Task,
PraisonAIAgents
)
def simple_callback(message=None, response=None, **kwargs):
with open('callback_log.txt', 'a') as f:
f.write(f"Received message: {message}\n")
f.write(f"Got response: {response}\n")
f.write(f"Other stuff: {kwargs}\n")
# Register as synchronous callback
register_display_callback('interaction', simple_callback, is_async=False)
# Create an agent
agent = Agent(
name="MyAgent",
role="Assistant",
goal="Help with tasks",
backstory="I am a helpful assistant",
llm="gemini/gemini-2.5-flash-lite-preview-06-17",
verbose=True
)
# Create a task
task = Task(
name="simple_task",
description="Say the number 1",
agent=agent,
expected_output="1"
)
# Run the agent
agents = PraisonAIAgents(
agents=[agent],
tasks=[task]
)
agents.start()
Steps to Reproduce
- install the library
- copy the scripts
- run the scripts to see the difference
Expected Behavior
Callbacks should be triggered regardless of the verbose setting.
Actual Behavior
Callbacks are only triggered when verbose=True.
Additional Context
This was tested using the register_display_callback interaction only
Description
The callback mechanism only triggers the callback when the agent is created with verbose=True.
Environment
Full Code
and
Steps to Reproduce
Expected Behavior
Callbacks should be triggered regardless of the verbose setting.
Actual Behavior
Callbacks are only triggered when verbose=True.
Additional Context
This was tested using the register_display_callback
interactiononly