Skip to content

Commit 4c7fa55

Browse files
committed
Convert timeout template to use Jinja2 for consistency
- Update _render_timeout_template to use Jinja2.Template instead of str.format() - Convert _TIMEOUT_TEMPLATE to use Jinja2 syntax ({{ variable }} instead of {variable}) - Add docstring to _render_timeout_template function - Improves consistency with other template rendering functions - Tested and verified correct rendering Resolves TODO in mini_swe_agent.py:109
1 parent 5fe0891 commit 4c7fa55

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/ares/code_agents/mini_swe_agent.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838

3939
# Copied from minisweagent's default config.
4040
_TIMEOUT_TEMPLATE = """
41-
The last command <command>{action}</command> timed out and has been killed.
41+
The last command <command>{{ action }}</command> timed out and has been killed.
4242
The output of the command was:
4343
<output>
44-
{output}
44+
{{ output }}
4545
</output>
4646
Please try another command and make sure to avoid those requiring interactive input.
4747
""".strip()
@@ -106,8 +106,19 @@ def _render_format_error_template(format_error_template: str, actions: list[str]
106106

107107

108108
def _render_timeout_template(action: str, output: str) -> str:
109-
# TODO: Use jinja2, and allow updating of configuration.
110-
return _TIMEOUT_TEMPLATE.format(action=action, output=output)
109+
"""Render the timeout error message using Jinja2.
110+
111+
Args:
112+
action: The action/command that timed out
113+
output: Any partial output from the command (may be empty)
114+
115+
Returns:
116+
Rendered timeout error message
117+
"""
118+
return jinja2.Template(_TIMEOUT_TEMPLATE, undefined=jinja2.StrictUndefined).render(
119+
action=action,
120+
output=output,
121+
)
111122

112123

113124
@dataclasses.dataclass(kw_only=True)

0 commit comments

Comments
 (0)