MCPcopy
hub / github.com/codeaashu/claude-code / getPreviousRequestIdFromMessages

Function getPreviousRequestIdFromMessages

src/services/api/claude.ts:928–938  ·  view source on GitHub ↗

* Extracts the request ID from the most recent assistant message in the * conversation. Used to link consecutive API requests in analytics so we can * join them for cache-hit-rate analysis and incremental token tracking. * * Deriving this from the message array (rather than global state) ensures

(
  messages: Message[],
)

Source from the content-addressed store, hash-verified

926 * independently, and rollback/undo naturally updates the value.
927 */
928function getPreviousRequestIdFromMessages(
929 messages: Message[],
930): string | undefined {
931 for (let i = messages.length - 1; i >= 0; i--) {
932 const msg = messages[i]!
933 if (msg.type === 'assistant' && msg.requestId) {
934 return msg.requestId
935 }
936 }
937 return undefined
938}
939
940function isMedia(
941 block: BetaContentBlockParam,

Callers 1

queryModelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected