Skip to content

Commit 39b0782

Browse files
committed
Increase default max_attempts to 10 and add pre-processing for common syntax errors in compile_and_fix_rust function
1 parent 4e73836 commit 39b0782

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/main.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,17 @@ async def compile_and_fix_rust(request: dict):
117117
if "code" not in request or "description" not in request:
118118
raise HTTPException(status_code=400, detail="Missing required fields")
119119

120-
max_attempts = request.get("max_attempts", 3)
120+
max_attempts = request.get("max_attempts", 10)
121+
122+
# Pre-process code to fix common syntax errors
123+
code = request["code"]
124+
# Fix missing parenthesis in println! macro
125+
if "println!(" in code and ");" not in code:
126+
code = code.replace("println!(\"", "println!(\"")
127+
code = code.replace("\" //", "\"); //")
121128

122129
result = rust_mcp.compile_and_fix_rust_code(
123-
request["code"],
130+
code,
124131
request["description"],
125132
max_attempts=max_attempts
126133
)

0 commit comments

Comments
 (0)