MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / stripAvatarFields

Function stripAvatarFields

packages/core/src/ai/content-parser.ts:38–54  ·  view source on GitHub ↗
(obj: unknown)

Source from the content-addressed store, hash-verified

36 * Used when serializing tool results to avoid transmitting large image data.
37 */
38export function stripAvatarFields(obj: unknown): void {
39 if (!obj || typeof obj !== 'object') return
40 if (Array.isArray(obj)) {
41 for (const item of obj) stripAvatarFields(item)
42 return
43 }
44 const record = obj as Record<string, unknown>
45 for (const key of Object.keys(record)) {
46 if ((key === 'avatar' || key === 'senderAvatar') && typeof record[key] === 'string') {
47 if ((record[key] as string).length > 200) {
48 record[key] = '[stripped]'
49 }
50 } else if (typeof record[key] === 'object' && record[key] !== null) {
51 stripAvatarFields(record[key])
52 }
53 }
54}

Callers 2

registerAiToolRoutesFunction · 0.90
executeRegistryToolFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected