- Add 5 new Agent configuration fields:
- compact_mode: Enable compact prompt mode to reduce context size
- tools_prompt_strategy: Choose between 'full' or 'names_only' for tools
- proactive_context_trimming: Enable proactive message trimming
- memory_max_chars: Cap memory context length
- knowledge_max_chars: Cap knowledge context length
- Implement compact prompt mode in utilities/prompts.py
- Caps role to 100 chars, goal to 150 chars
- Omits backstory entirely in compact mode
- Implement tools_prompt_strategy in Agent.create_agent_executor
- 'names_only' uses get_tool_names for minimal tool descriptions
- 'full' uses render_text_description_and_args (default)
- Implement memory/knowledge size bounds in Agent.execute_task
- Truncates memory and knowledge contexts when limits are set
- Add trim_messages_structurally helper in agent_utils.py
- Structural trimming without LLM calls
- Keeps system messages and last N message pairs
- Integrate proactive trimming in CrewAgentExecutor._invoke_loop
- Trims messages before each LLM call when enabled
- Update LangGraphAdapter and OpenAIAdapter to honor compact_mode
- Compacts role/goal/backstory in system prompts
- Add comprehensive tests for all new features:
- test_prompts_compact_mode.py
- test_memory_knowledge_truncation.py
- test_tools_prompt_strategy.py
- test_proactive_context_trimming.py
All changes are opt-in with conservative defaults to maintain backward compatibility.
Fixes#3912
Co-Authored-By: João <joao@crewai.com>