Skip to content

[FEATURE] Improve agent/task templating #2650

Open
@fmatray

Description

@fmatray

Feature Area

Core functionality

Is your feature request related to a an existing bug? Please link it here.

Today, agents and tasks yaml file only support basic replacement '{variable}' with few object types: int, float, int and bool.

It would be interesting to have more options, like:

  • Containers: List, Dict, Set, etc.
  • Standard objects: datetime, time, etc.
  • Custom objects: MyCustomObject

It would also nice to have more control, with if and loop statements, also with filtering options.

Of course, it's possible to do so doing before passing inputs.
However, it mixes the logic and data.

This could help to make more flexible agents, tasks and crew.

Describe the solution you'd like

An easy way, would be to implement a library like Jinja2 as a templating tool:

  • It's robust and well known library and easy to implement
  • it give a lot of control by having a clear separation between app's logic and agent/task templating

The main downside, is the incompatibility between action variables '{var}' and jinja ones {{var}}.

Describe alternatives you've considered

In src/crewai/utilities/string_utils.py, instead of validating with validate_type(), just to str(variable) with a try/except to handle errors.
As this can be an easy solution for some types like datetime, it can be more difficult with some kind of objects.

Moreover, it doesn't give any another control.

Additional context

No response

Willingness to Contribute

I can test the feature once it's implemented

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions