Skip to content

Template configuration

sweagent.agent.agents.TemplateConfig pydantic-model

Bases: BaseModel

This configuration is used to define almost all message templates that are formatted by the agent and sent to the LM.

Fields:

Validators:

command_cancelled_timeout_template pydantic-field

command_cancelled_timeout_template: str = "The command '{{command}}' was cancelled because it took more than {{timeout}} seconds. Please try a different command that completes more quickly."

Message template for when the agent's command was cancelled because it took too long. Available variables: timeout, command

demonstration_template pydantic-field

demonstration_template: str | None = None

demonstrations pydantic-field

demonstrations: list[Path]

Paths to demonstrations. If path is not absolute, it is assumed to be relative to the SWE_AGENT_CONFIG_ROOT (if set) or the SWE-agent repository root

instance_template pydantic-field

instance_template: str = ''

max_observation_length pydantic-field

max_observation_length: int = 100000

Truncate observation to this length if it exceeds it.

next_step_no_output_template pydantic-field

next_step_no_output_template: str = None

Template for the next step when the last output was empty. Defaults to next_step_template.

next_step_template pydantic-field

next_step_template: str = 'Observation: {{observation}}'

next_step_truncated_observation_template pydantic-field

next_step_truncated_observation_template: str = 'Observation: {{observation}}<response clipped><NOTE>Observations should not exceeded {{max_observation_length}} characters. {{elided_chars}} characters were elided. Please try a different command that produces less output or use head/tail/grep/redirect the output to a file. Do not use interactive pagers.</NOTE>'

Message template for when the agent's observation was truncated. Available variables: observation, max_observation_length, elided_chars

put_demos_in_history pydantic-field

put_demos_in_history: bool = False

If True, add demonstration to history instead of as a single message

shell_check_error_template pydantic-field

shell_check_error_template: str = 'Your bash command contained syntax errors and was NOT executed. Please fix the syntax errors and try again. This can be the result of not adhering to the syntax for multi-line commands. Here is the output of `bash -n`:\n{{bash_stdout}}\n{{bash_stderr}}'

Message template for when the agent's bash command contains syntax errors. Available variables: bash_stdout, bash_stderr

strategy_template pydantic-field

strategy_template: str | None = None

system_template pydantic-field

system_template: str = ''

validate_template_jinja_syntax pydantic-validator

validate_template_jinja_syntax() -> Self
Source code in sweagent/agent/agents.py
118
119
120
121
122
123
124
@model_validator(mode="after")
def validate_template_jinja_syntax(self) -> Self:
    template_fields = [field for field in self.model_fields.keys() if field.endswith("_template")]
    for field in template_fields:
        value = getattr(self, field)
        _warn_probably_wrong_jinja_syntax(value)
    return self

warn_models_in_history pydantic-validator

warn_models_in_history() -> Self
Source code in sweagent/agent/agents.py
126
127
128
129
130
131
@model_validator(mode="after")
def warn_models_in_history(self) -> Self:
    if self.put_demos_in_history and self.demonstration_template is not None:
        logger = get_logger("swea-config", emoji="🔧")
        logger.warning("demonstration_template is ignored when put_demos_in_history is True")
    return self