Skip to content

Callbacks Only Work When verbose=True #877

@mzazakeith

Description

@mzazakeith

Description

The callback mechanism only triggers the callback when the agent is created with verbose=True.

Environment

  • Provider (select one):
    • Anthropic
    • OpenAI
    • Google Vertex AI
    • AWS Bedrock
    • Other:
  • 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

  1. install the library
  2. copy the scripts
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions