Unflatten messages[] (in memory)
unflatten_messagesRe-inline tool_result markers in a flattened conversation by replacing each [FLATTENED id=...] marker with the matching entry from the extracted array, restoring the original messages.
Instructions
Restore a conversation flattened by flatten_messages: re-inlines every tool_result whose content is a [FLATTENED id=...] marker from the matching entry in "extracted", byte-for-byte. Markers with no matching entry are left in place. Purely functional — no disk, no network, input never mutated.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messages | Yes | The flattened messages[] array (the "messages" field of a flatten_messages result). | |
| extracted | Yes | The "extracted" array returned by flatten_messages for this conversation. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messages | Yes | The restored messages[] array, byte-for-byte identical to the pre-flatten conversation. Any [FLATTENED id=...] marker with no matching extracted entry is left in place. |