Callback Output is not generating after task complete #1479
Replies: 2 comments
-
|
This looks like the callback signature might not match what crewAI expects. Here are some things to check: 1. Check Callback SignaturecrewAI might expect a specific signature: def on_task_complete(output):
# output might be a TaskOutput object, not just a string
print(f"Output type: {type(output)}")
print(f"Output: {output}")
# If it's a TaskOutput object:
result = output.raw if hasattr(output, "raw") else str(output)
with open("output.txt", "w") as f:
f.write(result)2. Verify Callback is Being CalledAdd debugging to confirm execution: def on_task_complete(output):
print("CALLBACK TRIGGERED") # Should appear in console
with open("debug.txt", "w") as f:
f.write("Callback executed")
# Then your actual logic3. Alternative: Use Task StateIf callbacks are unreliable, capture output via state: state = {"task_outputs": {}}
result = crew.kickoff()
# After completion, all outputs are in result
for task_output in result.tasks_output:
state["task_outputs"][task_output.task_id] = task_output.raw
with open(f"output_{task_output.task_id}.txt", "w") as f:
f.write(task_output.raw)4. Check Version CompatibilityIn 0.28.0, the callback API might have changed. Check the changelog or try: @task
def my_task():
...
return result # Result goes to callbackCan you share what |
Beta Was this translation helpful? Give feedback.
-
|
A couple of things come to mind:
def on_task_complete(task_result):
print("Callback called!")
print(task_result)
with open("output.txt", "w") as f:
f.write(str(task_result))If you don't see
f.write(str(task_result))instead of: f.write(task_result)
import os
print(os.getcwd())
pip install -U crewaiCould you confirm:
That would help narrow down whether this is a callback issue, a file path issue, or a CrewAI 0.28.0 behavior difference. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have created the tasks and added the python callable function, but I invoke the kickoff function after the task completion there is not txt file getting created, this is the version I'm using crewai==0.28.0
This is my code, please help
Beta Was this translation helpful? Give feedback.
All reactions