( messages: Message[], endOf: 'agentStep' | 'userPrompt', )
| 296 | } |
| 297 | |
| 298 | export function expireMessages( |
| 299 | messages: Message[], |
| 300 | endOf: 'agentStep' | 'userPrompt', |
| 301 | ): Message[] { |
| 302 | return messages.filter((m) => { |
| 303 | // Keep messages with no timeToLive |
| 304 | if (m.timeToLive === undefined) return true |
| 305 | |
| 306 | // Remove messages that have expired |
| 307 | if (m.timeToLive === 'agentStep') return false |
| 308 | if (m.timeToLive === 'userPrompt' && endOf === 'userPrompt') return false |
| 309 | |
| 310 | return true |
| 311 | }) |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * Removes tool calls from the message history that don't have corresponding tool responses. |
no outgoing calls
no test coverage detected