Files
variet-agent/tests/test_quick.py

39 lines
1.3 KiB
Python

"""Debug: test --system flag with stdin."""
import asyncio, tempfile, os
async def test():
# Write system prompt to temp file
sys_file = tempfile.NamedTemporaryFile(mode="w", suffix=".md", delete=False, encoding="utf-8")
sys_file.write("You are a planner. Respond with a JSON object containing: summary, tasks array.")
sys_file.close()
ctx = "List 2 tasks to improve a Python project. Respond in JSON format."
print(f"System file: {sys_file.name}")
print(f"Context length: {len(ctx)}")
# Test 1: with --system
proc = await asyncio.create_subprocess_exec(
"cmd", "/c",
f"gemini --system {sys_file.name} --approval-mode yolo",
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
stdout, stderr = await asyncio.wait_for(
proc.communicate(input=ctx.encode("utf-8")),
timeout=90
)
out = stdout.decode('utf-8', errors='replace')
err = stderr.decode('utf-8', errors='replace')
lines = [l for l in out.splitlines() if "YOLO" not in l and "Loaded cached" not in l]
print(f"\nSTDOUT ({len(out)} bytes): {out[:500]}")
print(f"STDERR ({len(err)} bytes): {err[:500]}")
print(f"CLEANED: {'|'.join(lines[:10])}")
os.unlink(sys_file.name)
asyncio.run(test())