Callback Output is not generating after task complete #1479
Unanswered
pip-install-skills
asked this question in
Q&A
Replies: 1 comment
-
|
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.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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