crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG] the output_file attribute is not working, if its configured in yaml file -- Interpolation is not working for output_file attribute

Open paarttipaabhalaji opened this issue 11 months ago • 5 comments

Description

If I configured the output_file attribute in tasks.yaml file, the output file is not getting generated. Task.yaml

Task_Name: > description: > ........ expected_output: > .......... Agent: > ........... output_file: > {Out_Dir}/InternalDesignDocument/{TriggerDt}/{ClassName}/{ClassName}_{method_name}InternalDesignDocument{DateAndTime}.md

Steps to Reproduce

sample Tasks.yaml

Task_Name: > description: > ........ expected_output: > .......... Agent: > ........... output_file: > {Out_Dir}/InternalDesignDocument/{TriggerDt}/{ClassName}/{ClassName}_{method_name}InternalDesignDocument{DateAndTime}.md

generate the output file using tasks.yaml

Expected behavior

the output file should generate in specified format in tasks.yaml

Screenshots/Code snippets

I have verified in local, the output file is getting generated but not in specified format. image

Operating System

macOS Sonoma

Python Version

3.12

crewAI Version

crewai[tools]>=0.86.0,<1.0.0

crewAI Tools Version

crewai-tools==0.17.0

Virtual Environment

Venv

Evidence

I have verified in local, the output file is not getting generated.

Possible Solution

Enable the interpolation for the attribute "output_file", when we used it in the tasks.yaml

Additional context

please fix it soon. If the interpolation is enable for the output file attribute, then its easy to make the file name flexible at runtime.

paarttipaabhalaji avatar Dec 25 '24 15:12 paarttipaabhalaji

It looks like the relevant code is here: https://github.com/crewAIInc/crewAI/blob/main/src/crewai/task.py#L511

Without interpolation based on inputs, output_file is unusable with kickoff_for_each

Crew team, if you don't view interpolation as a requirement, please indicate the recommended workaround. (It looks like perhaps callback functions should be used, however the callback doesn't receive the crew inputs): https://docs.crewai.com/concepts/tasks#callback-mechanism)

twschiller avatar Dec 29 '24 02:12 twschiller

Just merged a PR that allows you to use interpolation on output_file, it will be in the new version we will cut between today and Monday :)

Callback and after and before kickoff hook could be useful as well (https://docs.crewai.com/concepts/crews#example-crew-class-with-decorators) -- The before hook do get the input and the after the result.

There is also a new feature we will be launching with programatic guardrails that could help, it will be out in this new version.

But again with this change to the interpolation for output_file you might not need any workarounds

joaomdmoura avatar Dec 29 '24 05:12 joaomdmoura

Thank you so much for the update @joaomdmoura .

paarttipaabhalaji avatar Dec 29 '24 13:12 paarttipaabhalaji

Hi @joaomdmoura . I have one query. The output file attribute allow us to append the results of each kickoff, if the file is exists ?

paarttipaabhalaji avatar Dec 30 '24 11:12 paarttipaabhalaji

Just merged a PR that allows you to use interpolation on output_file, it will be in the new version we will cut between today and Monday :)

Thanks @joaomdmoura! Any updates on release timeline? Looks like the latest release was Dec 5?: https://pypi.org/project/crewai/#history

twschiller avatar Dec 31 '24 13:12 twschiller

Confirmed this is working for me in 0.95.0. Looks like you can close out the issue?

twschiller avatar Jan 14 '25 14:01 twschiller

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Feb 14 '25 12:02 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Feb 20 '25 12:02 github-actions[bot]