diff --git a/agent/tests/test_write_confirmation.py b/agent/tests/test_write_confirmation.py index 8dbc0e0..f333282 100644 --- a/agent/tests/test_write_confirmation.py +++ b/agent/tests/test_write_confirmation.py @@ -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}) diff --git a/agent/write_confirmation.py b/agent/write_confirmation.py index a2305b9..91bd8f6 100644 --- a/agent/write_confirmation.py +++ b/agent/write_confirmation.py @@ -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)