MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / expireMessages

Function expireMessages

packages/agent-runtime/src/util/messages.ts:298–312  ·  view source on GitHub ↗
(
  messages: Message[],
  endOf: 'agentStep' | 'userPrompt',
)

Source from the content-addressed store, hash-verified

296}
297
298export 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.

Callers 2

runAgentStepFunction · 0.90
loopAgentStepsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected