diff --git a/scripts/mma_exec.py b/scripts/mma_exec.py index 96e06cb..4008c6b 100644 --- a/scripts/mma_exec.py +++ b/scripts/mma_exec.py @@ -125,6 +125,7 @@ def execute_agent(role: str, prompt: str, docs: list[str]) -> str: if doc.endswith('.py') and os.path.exists(doc): deps = get_dependencies(doc) for dep in deps: + # Only try to generate skeletons for files that exist in the local dir dep_file = f"{dep}.py" if os.path.exists(dep_file) and dep_file != doc: try: @@ -133,6 +134,10 @@ def execute_agent(role: str, prompt: str, docs: list[str]) -> str: injected_context += f"\n\nDEPENDENCY SKELETON: {dep_file}\n{skeleton}\n" except Exception as e: print(f"Error generating skeleton for {dep_file}: {e}") + + # Check for token-bloat safety: if injected_context is too large, truncate it + if len(injected_context) > 10000: + injected_context = injected_context[:10000] + "... [TRUNCATED FOR COMMAND LINE LIMITS]" # MMA Protocol: Tier 3 and 4 are stateless and tool-less. system_directive = f"STRICT SYSTEM DIRECTIVE: You are a stateless {role}. " \ @@ -183,14 +188,13 @@ def main(): args = parser.parse_args() docs = get_role_documents(args.role) - # We allow the user to provide additional docs if they want? - # For now, just the default role docs. - # In practice, conductor will call this with a prompt like "Modify aggregate.py @aggregate.py" - # But wait, my execute_agent expects docs as a list. - # If the prompt contains @file, we should extract it and put it in docs. - # Actually, gemini CLI handles @file positionals. - # But my execute_agent appends them to command_text as @file. + # Extract @file references from the prompt + import re + file_refs = re.findall(r"@([\w./\\]+)", args.prompt) + for ref in file_refs: + if os.path.exists(ref) and ref not in docs: + docs.append(ref) print(f"Executing role: {args.role} with docs: {docs}") result = execute_agent(args.role, args.prompt, docs)