@@ -405,10 +405,72 @@ def _persist_failed_results(results, strategy: str) -> None:
405405 )
406406
407407
408+ # Field whitelist whose strings get aggressively trimmed when rendering the
409+ # YAML payload inside markdown output (full data is still emitted by
410+ # `--format yaml` and `--output-yaml`).
411+ _MARKDOWN_TRUNCATE_FIELDS : frozenset [str ] = frozenset ({
412+ "response" ,
413+ "message" ,
414+ "validation_message" ,
415+ "error" ,
416+ "stdout" ,
417+ "stderr" ,
418+ })
419+
420+ _MARKDOWN_TRUNCATE_LIMIT = 240
421+
422+
423+ def _truncate_long_strings_for_markdown (
424+ value : Any ,
425+ * ,
426+ limit : int = _MARKDOWN_TRUNCATE_LIMIT ,
427+ parent_field : Optional [str ] = None ,
428+ ) -> Any :
429+ """Recursively shorten long string values for human-readable markdown output.
430+
431+ Only strings reached via a key in :data:`_MARKDOWN_TRUNCATE_FIELDS` are
432+ truncated; everything else is passed through unchanged. The mutation is
433+ done on a deep copy so the original payload (used for ``--format yaml``
434+ and ``--output-yaml``) is not affected.
435+ """
436+ if isinstance (value , dict ):
437+ return {
438+ key : _truncate_long_strings_for_markdown (
439+ item , limit = limit , parent_field = str (key )
440+ )
441+ for key , item in value .items ()
442+ }
443+ if isinstance (value , list ):
444+ return [
445+ _truncate_long_strings_for_markdown (item , limit = limit , parent_field = parent_field )
446+ for item in value
447+ ]
448+ if isinstance (value , tuple ):
449+ return tuple (
450+ _truncate_long_strings_for_markdown (item , limit = limit , parent_field = parent_field )
451+ for item in value
452+ )
453+ if (
454+ isinstance (value , str )
455+ and parent_field in _MARKDOWN_TRUNCATE_FIELDS
456+ and len (value ) > limit
457+ ):
458+ omitted = len (value ) - limit
459+ suffix = f"… <truncated { omitted } chars; use --format yaml or --output-yaml for full output>"
460+ return value [:limit ].rstrip () + suffix
461+ return value
462+
463+
408464def _build_results_markdown (payload : dict [str , Any ]) -> str :
409- """Build markdown output with YAML payload codeblock."""
465+ """Build markdown output with a compact YAML payload codeblock.
466+
467+ Long fields like ``response`` are truncated to keep terminal output
468+ readable; the full payload is still emitted by ``--format yaml`` and
469+ ``--output-yaml``.
470+ """
410471 summary = payload .get ("summary" , {})
411- yaml_payload = _yaml .safe_dump (payload , sort_keys = False , allow_unicode = True ).rstrip ()
472+ compact_payload = _truncate_long_strings_for_markdown (payload )
473+ yaml_payload = _yaml .safe_dump (compact_payload , sort_keys = False , allow_unicode = True ).rstrip ()
412474
413475 lines = [
414476 "## Execution Summary" ,
0 commit comments