Skip to content

fix(models): handle repeated title headings - #272

Open
AoHanBei wants to merge 1 commit into
ANative-Lab:mainfrom
AoHanBei:fix/repeated-title-headings
Open

fix(models): handle repeated title headings#272
AoHanBei wants to merge 1 commit into
ANative-Lab:mainfrom
AoHanBei:fix/repeated-title-headings

Conversation

@AoHanBei

Copy link
Copy Markdown

Fixes #271

Problem

In title parse mode, a repeated field heading is no longer recognized after its first occurrence. The repeated heading and its value are appended to the previous section, which can either raise a parsing error for typed fields or silently produce an incorrect value.

Root cause

_parse_title_content removed each recognized heading from output_titles. Once removed, a later occurrence of the same heading could no longer start a new section.

Changes

  • Keep formatted headings available throughout the complete parse.
  • Map each formatted heading directly to its declared attribute name.
  • Preserve last-value-wins behavior when a heading appears more than once.
  • Add regression coverage for repeated int, bool, and str headings.

Validation

  • pytest tests/src/models -q -p no:cacheprovider — 37 passed
  • pytest tests/src/agents/test_customize_agent_config.py tests/src/agents/test_customize_action.py -q -p no:cacheprovider — 54 passed
  • ruff check tests/src/models/test_base_model.py — passed
  • git diff --check — passed

The complete suite produced 233 passes and 22 Windows-only benchmark failures. Twenty failures come from the existing os.path.exists(path=...) call, which is rejected by Windows ntpath; the other two are existing LiveCodeBench execution differences on Windows. None involve the modified parser or its adjacent modules.

Compatibility

This does not change the public API or parsing format. Repeated headings now follow the parser's existing assignment behavior, where the latest recognized section replaces the earlier value.

AI assistance

AI assistance was used during investigation, implementation, and regression-test drafting. I reviewed the final diff and test results and take responsibility for the submitted change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Repeated field heading in title parse mode corrupts the next field and breaks parsing

1 participant