fix(mma): Use headless execution flag for context amnesia and parse json output

This commit is contained in:
2026-02-25 19:45:59 -05:00
parent 7273e3f718
commit f6e6d418f6
2 changed files with 21 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
import argparse
import subprocess
import json
def get_role_documents(role: str) -> list[str]:
if role == 'tier1':
@@ -15,9 +16,24 @@ def execute_agent(role: str, prompt: str, docs: list[str]) -> str:
for doc in docs:
command_text += f" @{doc}"
cmd = ["gemini", command_text]
process = subprocess.run(cmd, capture_output=True, text=True)
return process.stdout
cmd = ['gemini', '-p', command_text, '--output-format', 'json', '--model', 'gemini-2.5-flash-lite']
try:
process = subprocess.run(cmd, capture_output=True, text=True, shell=True)
if not process.stdout and process.stderr:
return f"Error: {process.stderr}"
stdout = process.stdout
start_index = stdout.find('{')
if start_index != -1:
json_str = stdout[start_index:]
try:
data = json.loads(json_str)
return data.get('response', stdout)
except json.JSONDecodeError:
return stdout
return stdout
except Exception as e:
return f"Execution failed: {str(e)}"
def create_parser():
parser = argparse.ArgumentParser(description="MMA Execution Script")

View File

@@ -64,7 +64,8 @@ def test_execute_agent():
cmd_list = args[0]
assert cmd_list[0] == "gemini"
assert cmd_list[1] == expected_gemini_arg
assert cmd_list[1] == "-p"
assert cmd_list[2] == expected_gemini_arg
assert kwargs.get("capture_output") is True
assert kwargs.get("text") is True