Previously, setting prompt_file on a Crew had no effect on agents, tasks,
tools, or any other components. The custom I18N instance was only used for
the manager agent's role/goal/backstory in hierarchical mode, while all
other code used the hardcoded I18N_DEFAULT singleton.
This fix introduces a contextvars-based mechanism that scopes a custom I18N
instance to the crew's execution:
- Added get_crew_i18n() / set_crew_i18n() / reset_crew_i18n() to i18n.py
using a ContextVar for thread-safe crew-scoped I18N overrides
- prepare_kickoff() now sets the crew's I18N when prompt_file is provided
- Crew.kickoff() resets the I18N context in its finally block (even on errors)
- Replaced all I18N_DEFAULT references with get_crew_i18n() calls across
29 source files so every component (Prompts, Task, agent tools, tool usage,
memory, reasoning, etc.) respects the crew's prompt_file
Added 12 new tests covering:
- Context variable set/get/reset/nesting behavior
- Prompts class using custom I18N
- Task.prompt() using custom I18N
- AgentTools delegation tools using custom I18N
- Full Crew.kickoff() integration (sets context, resets on success/exception)
Co-Authored-By: João <joao@crewai.com>