Function
withMessageHistory
({
runState,
messages,
}: {
runState: RunState
messages: Message[]
})
Source from the content-addressed store, hash-verified
| 667 | } |
| 668 | |
| 669 | export function withMessageHistory({ |
| 670 | runState, |
| 671 | messages, |
| 672 | }: { |
| 673 | runState: RunState |
| 674 | messages: Message[] |
| 675 | }): RunState { |
| 676 | // Deep copy |
| 677 | const newRunState = JSON.parse(JSON.stringify(runState)) as typeof runState |
| 678 | |
| 679 | if (newRunState.sessionState) { |
| 680 | newRunState.sessionState.mainAgentState.messageHistory = messages |
| 681 | } |
| 682 | |
| 683 | return newRunState |
| 684 | } |
| 685 | |
| 686 | /** |
| 687 | * Applies overrides to an existing session state, allowing specific fields to be updated |