fix: join root task sections with newlines

build_root_task assembled section headers and per-item bullets as
separate list elements, then joined them with a single space. Scans
with more than one target (or diff-scope constraints) rendered every
bullet on one run-on line, e.g. "URLs: - a - b" instead of a proper
list. Join with a newline to match the sibling child_initial_input
builder. Add a regression test covering multiple targets.

Closes #682
This commit is contained in:
Sean Kim 2026-07-04 12:44:06 -07:00
parent 302efedca6
commit 1bf4310f60
2 changed files with 15 additions and 1 deletions

View file

@ -73,7 +73,7 @@ def build_root_task(scan_config: dict[str, Any]) -> str:
if deleted:
parts.append(f"- {label}: {deleted} deleted file(s) are context-only")
task = " ".join(parts)
task = "\n".join(parts)
if user_instructions:
task = f"{task}\n\nSpecial instructions: {user_instructions}"
return task

View file

@ -93,6 +93,20 @@ def test_build_root_task_web_application_with_instructions() -> None:
assert "Special instructions: Focus on auth." in task
def test_build_root_task_multiple_targets_are_newline_separated() -> None:
config = {
"targets": [
{"type": "web_application", "details": {"target_url": "https://a.example.com"}},
{"type": "web_application", "details": {"target_url": "https://b.example.com"}},
],
}
task = build_root_task(config)
assert "\n- https://a.example.com" in task
assert "\n- https://b.example.com" in task
assert "https://a.example.com - https://b.example.com" not in task
def test_build_root_task_diff_scope() -> None:
config = {
"targets": [],