Skip to content

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: Correctly display merged config dict

Kilian Lieretd746b3a92182
diff --git a/sweagent/run/common.py b/sweagent/run/common.py
index fbbbc9a6..74df9a10 100644
--- a/sweagent/run/common.py
+++ b/sweagent/run/common.py
@@ -18,6 +18,7 @@ from rich.panel import Panel
from sweagent import CONFIG_DIR
from sweagent.types import AgentInfo, AgentRunResult
from sweagent.utils.log import get_logger
+from sweagent.utils.serialization import merge_nested_dicts
def _shorten_strings(data, *, max_length=30):
@@ -331,7 +332,7 @@ class BasicCLI:
Panel.fit(
"[red][bold]Merged configuration\n[/bold]"
"This is the merged configuration that was used to instantiate the config object[/red]\n\n"
- + yaml.dump(_shorten_strings(config_merged | cl_options_dict))
+ + yaml.dump(_shorten_strings(merge_nested_dicts(config_merged, cl_options_dict)))
)
)
rich_print(
diff --git a/sweagent/utils/serialization.py b/sweagent/utils/serialization.py
index f1888e14..4edc0500 100644
--- a/sweagent/utils/serialization.py
+++ b/sweagent/utils/serialization.py
@@ -31,3 +31,12 @@ def _yaml_serialization_with_linebreaks(data: Any) -> str:
buffer = io.StringIO()
yaml.dump(data, buffer)
return buffer.getvalue()
+
+
+def merge_nested_dicts(d1: dict, d2: dict) -> dict:
+ for key, value in d2.items():
+ if isinstance(value, dict):
+ d1[key] = merge_nested_dicts(d1.get(key, {}), value)
+ else:
+ d1[key] = value
+ return d1