From 48b5cfd0851e8f330ab7f7a0c158a709e68deb39 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Mon, 16 Feb 2026 22:40:31 -0800 Subject: [PATCH] Add skip_context_files option to AIAgent for batch processing - Introduced a new parameter `skip_context_files` in the AIAgent class to control the inclusion of context files (SOUL.md, AGENTS.md, .cursorrules) in the system prompt. - Updated the _process_single_prompt function to set `skip_context_files` to True, preventing pollution of trajectories during batch processing and data generation. --- batch_runner.py | 1 + run_agent.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/batch_runner.py b/batch_runner.py index 9a3f3e3b4..f3ba448f3 100644 --- a/batch_runner.py +++ b/batch_runner.py @@ -276,6 +276,7 @@ def _process_single_prompt( max_tokens=config.get("max_tokens"), reasoning_config=config.get("reasoning_config"), prefill_messages=config.get("prefill_messages"), + skip_context_files=True, # Don't pollute trajectories with SOUL.md/AGENTS.md ) # Run the agent with task_id to ensure each task gets its own isolated VM diff --git a/run_agent.py b/run_agent.py index a5ca45603..17d285658 100644 --- a/run_agent.py +++ b/run_agent.py @@ -1013,6 +1013,7 @@ class AIAgent: reasoning_config: Dict[str, Any] = None, prefill_messages: List[Dict[str, Any]] = None, platform: str = None, + skip_context_files: bool = False, ): """ Initialize the AI Agent. @@ -1045,6 +1046,9 @@ class AIAgent: Example: [{"role": "user", "content": "Hi!"}, {"role": "assistant", "content": "Hello!"}] platform (str): The interface platform the user is on (e.g. "cli", "telegram", "discord", "whatsapp"). Used to inject platform-specific formatting hints into the system prompt. + skip_context_files (bool): If True, skip auto-injection of SOUL.md, AGENTS.md, and .cursorrules + into the system prompt. Use this for batch processing and data generation to avoid + polluting trajectories with user-specific persona or project instructions. """ self.model = model self.max_iterations = max_iterations @@ -1054,6 +1058,7 @@ class AIAgent: self.quiet_mode = quiet_mode self.ephemeral_system_prompt = ephemeral_system_prompt self.platform = platform # "cli", "telegram", "discord", "whatsapp", etc. + self.skip_context_files = skip_context_files self.log_prefix_chars = log_prefix_chars self.log_prefix = f"{log_prefix} " if log_prefix else "" # Store effective base URL for feature detection (prompt caching, reasoning, etc.) @@ -2016,9 +2021,11 @@ class AIAgent: prompt_parts.append(skills_prompt) # Auto-include context files (SOUL.md, AGENTS.md, .cursorrules). - context_files_prompt = build_context_files_prompt() - if context_files_prompt: - prompt_parts.append(context_files_prompt) + # Skipped for batch processing / data generation to avoid polluting trajectories. + if not self.skip_context_files: + context_files_prompt = build_context_files_prompt() + if context_files_prompt: + prompt_parts.append(context_files_prompt) # Current local date and time so the model is never confused about # what day/time it is (LLM training cutoffs can otherwise mislead it).