Skip to content

Preserve JSON validity when paging list-valued recipe sections #4341

Description

@Trecek

Problem

get_recipe_section serializes the list-valued errors, warnings, and
ingredients_table sections as JSON and then applies character-offset
chunking. When a section exceeds the delivery bound, a returned content
fragment can split a JSON token or list element and cannot be parsed
independently.

This is residual class 1 from #4314, verified on develop at ac8f653a0
after PR #4330.

Current behavior

  • _bounded_recipe_section_response in
    src/autoskillit/server/tools/tools_recipe.py accepts a string and slices it
    at character offsets.
  • get_recipe_section passes JSON-serialized strings for errors, warnings,
    and ingredients_table.
  • Existing continuation tests cover reconstructed raw/YAML content, not the
    parsing contract for these list-valued sections.
  • Current tool and sous-chef guidance does not explicitly define
    concatenate-before-parse behavior.

Required outcome

  • Define one explicit, machine-consumable pagination contract for list-valued
    recipe sections.
  • Preserve list-element boundaries so every successful page is independently
    valid JSON and retains its original element values and ordering.
  • Keep every serialized tool response within the effective delivery byte bound,
    including multibyte data and a single element that cannot fit on an ordinary
    page.
  • Return an explicit bounded failure or continuation representation for an
    individually oversized element; do not silently drop it or return an invalid
    fragment.
  • Preserve the existing continuation metadata contract (part, total_parts,
    has_more, and next_part) and the behavior of string-valued sections.
  • Document the list-page consumption contract in the public tool guidance used
    by agents.

Verification

Add regression coverage for all three list-valued sections:

  1. Multiple pages round-trip through JSON parsing and reconstruct the original
    ordered list.
  2. Each complete tool response respects the effective byte bound.
  3. Multibyte values and a single oversized element have deterministic,
    lossless behavior.
  4. Invalid part values fail explicitly.
  5. Existing string/YAML continuation behavior remains unchanged.

Provenance and boundaries

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugExisting behavior is brokenrecipe:remediationRoute: investigate/decompose before implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions