Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions agent/tests/test_write_confirmation.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@ def test_summarize_args_joins_lists_and_compacts_nested_values():
}


def test_summarize_args_renders_list_items_like_top_level_values():
fields = summarize_args(
{
"pages": [{"title": "Q3 plan"}, {"title": "Q4 plan"}],
"flags": [True, False],
}
)

assert fields == [
{
"label": "Pages",
"value": '{"title": "Q3 plan"}, {"title": "Q4 plan"}',
},
{"label": "Flags", "value": "Yes, No"},
]


def test_summarize_args_truncates_an_overlong_value():
fields = summarize_args({"description": "x" * 400})

Expand Down
4 changes: 3 additions & 1 deletion agent/write_confirmation.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def _stringify(value) -> str:
if isinstance(value, bool):
return "Yes" if value else "No"
if isinstance(value, (list, tuple)):
return ", ".join(str(v) for v in value)
# Each item the way it would read on its own: a list of objects is
# still JSON, not Python's repr of it.
return ", ".join(_stringify(v) for v in value)
if isinstance(value, dict):
return json.dumps(value, ensure_ascii=False, default=str)
return str(value)
Expand Down