Skip to content

fix: #3319 preserve nested handoff history content#3320

Open
Aphroq wants to merge 2 commits intoopenai:mainfrom
Aphroq:fix/handoff-history-structured-lines
Open

fix: #3319 preserve nested handoff history content#3320
Aphroq wants to merge 2 commits intoopenai:mainfrom
Aphroq:fix/handoff-history-structured-lines

Conversation

@Aphroq
Copy link
Copy Markdown
Contributor

@Aphroq Aphroq commented May 9, 2026

Summary

  • Preserve multiline message content when flattening an already nested handoff-history summary.
  • Preserve structured role content by serializing those summary entries as JSON and parsing them back before the next history mapper runs.
  • Keep the existing readable role: content format for simple string messages, and keep legacy summary parsing for older saved histories.

Test plan

  • bash .agents/skills/code-change-verification/scripts/run.sh

Issue number

Closes #3319

Checks

  • I've added new tests (if relevant)
  • I've added/updated the relevant documentation
  • I've run make lint and make format
  • I've made sure tests pass

@github-actions github-actions Bot added bug Something isn't working feature:core labels May 9, 2026
Copy link
Copy Markdown
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. I agree this is a real scenario: chained nest_handoff_history can receive multiline user content or structured/multimodal content, and preserving that transcript shape is important.

Before merging, could you make one small follow-up change? The new record splitter still treats a continuation line like 2. not a new record as a new summary item, so multiline string content can still be truncated when a later line happens to look like a numbered summary record.

Could we serialize role items with string content that contains newlines using the JSON record format as well? That should remove the ambiguity for newly generated summaries while keeping the legacy parser for older saved histories. Please also add a regression test for a multiline string where the second line starts with something like 2. not a new record.

@seratch seratch marked this pull request as draft May 9, 2026 23:57
@Aphroq Aphroq force-pushed the fix/handoff-history-structured-lines branch from fed27b7 to 6b9de69 Compare May 10, 2026 05:57
@Aphroq
Copy link
Copy Markdown
Contributor Author

Aphroq commented May 10, 2026

Thanks for the review.

I changed the formatter so role items with string content that contains \n or \r now use the JSON record format too. Simple one-line string messages still keep the readable role: content format, and the legacy parser still handles older saved summaries.

I also updated the multiline regression test to use first line\n2. not a new record, so the new summary path no longer depends on the record splitter guessing whether that second line is content or a new item.

I checked the adjacent cases as well: structured/multimodal role content still round-trips through JSON, legacy multiline summaries still parse, role+name formatting is preserved for simple strings, non-role items still serialize as JSON, provider_data is still stripped, and the existing custom-wrapper/unserializable fallback tests still pass.

@Aphroq Aphroq marked this pull request as ready for review May 10, 2026 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested handoff history flattening drops multiline and structured content

2 participants