Skip to content

Specifying problems

We currently support the following input types:

  • A string of text (TextProblemStatement)
  • A path to a file on the local filesystem (FileProblemStatement)
  • A URL to a GitHub issue (GithubIssue)
  • An empty problem statement (EmptyProblemStatement)

With sweagent run, you can specify the problem statement type with the --problem-statement flag. For example:

From text
--problem-statement.text="This is a problem statement"
--problem-statement.type=text
From a file
--problem-statement.path=path/to/file.txt
--problem-statement.type=text_file
From a GitHub issue
--problem-statement.url=https://github.com/org/repo/issues/123
--problem-statement.type=github_issue

See below for more details on the configuration options.

All of these classes are defined in sweagent.agent.problem_statement.

problem_statement_from_simplified_input

problem_statement_from_simplified_input(*, input: str, type: Literal['text', 'text_file', 'github_issue', 'swe_bench_multimodal']) -> ProblemStatementConfig

Get a problem statement from an input string and a type.

Parameters:

Name Type Description Default
input str

Url/path/text

required
type Literal['text', 'text_file', 'github_issue', 'swe_bench_multimodal']

The type of problem statement

required
Source code in sweagent/agent/problem_statement.py
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
def problem_statement_from_simplified_input(
    *, input: str, type: Literal["text", "text_file", "github_issue", "swe_bench_multimodal"]
) -> ProblemStatementConfig:
    """Get a problem statement from an `input` string and a `type`.

    Args:
        input: Url/path/text
        type: The type of problem statement
    """
    if type == "text":
        return TextProblemStatement(text=input)
    elif type == "text_file":
        return FileProblemStatement(path=Path(input))
    elif type == "github_issue":
        return GithubIssue(github_url=input)
    elif type == "swe_bench_multimodal":
        return SWEBenchMultimodalProblemStatement(text=input)
    else:
        msg = f"Unknown problem statement type: {type}"
        raise ValueError(msg)

TextProblemStatement pydantic-model

Config:

  • extra: forbid

Fields:

text pydantic-field

text: str

extra_fields pydantic-field

extra_fields: dict[str, Any]

Any additional data to be added to the instance. This data will be available when formatting prompt templates.

type pydantic-field

type: Literal['text'] = 'text'

Discriminator for (de)serialization/CLI. Do not change.

id pydantic-field

id: str = None

get_problem_statement

get_problem_statement() -> str
Source code in sweagent/agent/problem_statement.py
88
89
def get_problem_statement(self) -> str:
    return self.text

get_extra_fields

get_extra_fields() -> dict[str, Any]
Source code in sweagent/agent/problem_statement.py
91
92
def get_extra_fields(self) -> dict[str, Any]:
    return self.extra_fields

FileProblemStatement pydantic-model

Config:

  • extra: forbid

Fields:

path pydantic-field

path: Path

extra_fields pydantic-field

extra_fields: dict[str, Any]

Any additional data to be added to the instance. This data will be available when formatting prompt templates.

type pydantic-field

type: Literal['text_file'] = 'text_file'

Discriminator for (de)serialization/CLI. Do not change.

id pydantic-field

id: str = None

get_problem_statement

get_problem_statement() -> str
Source code in sweagent/agent/problem_statement.py
121
122
def get_problem_statement(self) -> str:
    return self.path.read_text()

get_extra_fields

get_extra_fields() -> dict[str, Any]
Source code in sweagent/agent/problem_statement.py
124
125
def get_extra_fields(self) -> dict[str, Any]:
    return self.extra_fields

GithubIssue pydantic-model

Config:

  • extra: forbid

Fields:

github_url pydantic-field

github_url: str

extra_fields pydantic-field

extra_fields: dict[str, Any]

Any additional data to be added to the instance. This data will be available when formatting prompt templates.

type pydantic-field

type: Literal['github'] = 'github'

Discriminator for (de)serialization/CLI. Do not change.

id pydantic-field

id: str = None

get_problem_statement

get_problem_statement() -> str
Source code in sweagent/agent/problem_statement.py
149
150
151
def get_problem_statement(self) -> str:
    owner, repo, issue_number = _parse_gh_issue_url(self.github_url)
    return _get_problem_statement_from_github_issue(owner, repo, issue_number, token=os.getenv("GITHUB_TOKEN"))

get_extra_fields

get_extra_fields() -> dict[str, Any]
Source code in sweagent/agent/problem_statement.py
153
154
def get_extra_fields(self) -> dict[str, Any]:
    return self.extra_fields

EmptyProblemStatement pydantic-model

Config:

  • extra: forbid

Fields:

  • id (str)
  • type (Literal['empty'])

id pydantic-field

id: str

type pydantic-field

type: Literal['empty'] = 'empty'

Discriminator for (de)serialization/CLI. Do not change.

get_problem_statement

get_problem_statement() -> str
Source code in sweagent/agent/problem_statement.py
64
65
def get_problem_statement(self) -> str:
    return ""