SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
Fix: Handle non-string values in tool call (#1164)
Kilian Lieret7f8304ab0af1
diff --git a/sweagent/tools/parsing.py b/sweagent/tools/parsing.pyindex 6a657055..d2aaff98 100644--- a/sweagent/tools/parsing.py+++ b/sweagent/tools/parsing.py@@ -39,7 +39,7 @@ import textwrapfrom abc import ABC, abstractmethodfrom shlex import quotefrom textwrap import dedent-from typing import Literal+from typing import Any, Literalfrom jinja2 import Templatefrom pydantic import BaseModel@@ -415,10 +415,17 @@ class FunctionCallingParser(AbstractParseFunction, BaseModel):if extra_args:msg = f"Unexpected argument(s): {', '.join(extra_args)}"raise FunctionCallingFormatError(msg, "unexpected_arg")++ def get_quoted_arg(value: Any) -> str:+ if isinstance(value, str):+ return quote(value) if _should_quote(value, command) else value+ # See https://github.com/SWE-agent/SWE-agent/issues/1159+ if value is None:+ return ""+ return str(value)+formatted_args = {- arg.name: Template(arg.argument_format).render(- value=quote(values[arg.name]) if _should_quote(values[arg.name], command) else values[arg.name]- )+ arg.name: Template(arg.argument_format).render(value=get_quoted_arg(values[arg.name]))if arg.name in valueselse ""for arg in command.arguments