{"record":{"id":"5c2aa330230ccccf","repo":"vercel/ai","slug":"maxinputbytespercall-must-be-greater-than-0","errorCode":null,"errorMessage":"maxInputBytesPerCall must be greater than 0","messagePattern":"maxInputBytesPerCall must be greater than 0","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ai/src/embed/embed-many.ts","lineNumber":455,"sourceCode":"}\n\nconst textEncoder = new TextEncoder();\n\nfunction splitByEmbeddingLimits({\n  values,\n  maxEmbeddingsPerCall,\n  maxInputBytesPerCall,\n}: {\n  values: Array<string>;\n  maxEmbeddingsPerCall: number;\n  maxInputBytesPerCall: number;\n}): Array<Array<string>> {\n  if (maxEmbeddingsPerCall <= 0) {\n    throw new Error('maxEmbeddingsPerCall must be greater than 0');\n  }\n\n  if (maxInputBytesPerCall <= 0) {\n    throw new Error('maxInputBytesPerCall must be greater than 0');\n  }\n\n  if (values.length === 0) {\n    return [];\n  }\n\n  const chunks: Array<Array<string>> = [];\n  let currentChunk: Array<string> = [];\n  let currentInputBytes = 0;\n\n  for (const value of values) {\n    const inputBytes = textEncoder.encode(value).length;\n\n    if (\n      currentChunk.length > 0 &&\n      (currentChunk.length >= maxEmbeddingsPerCall ||\n        currentInputBytes + inputBytes > maxInputBytesPerCall)\n    ) {","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/embed/embed-many.ts#L437-L473","documentation":"Each skill must have a unique name, since the name becomes its directory under the skills root. validateACPSkills tracks names in a set and throws on the second occurrence. Duplicates would silently overwrite each other's files, so they are rejected up front.","triggerScenarios":"Passing an array of skills to the ACP harness where two entries share the same name (e.g. merging skill lists from multiple sources without deduplication).","commonSituations":"Concatenating project-level and user-level skill collections that both define a 'code-reviewer' skill; loading skills from several directories with clashing basenames; generating skills in a loop with a reused name.","solutions":["Deduplicate skills by name before passing them (keep the intended one, e.g. project over user-level).","Rename one of the conflicting skills to a distinct kebab-case slug.","Detect conflicts early by building a Set of names and asserting uniqueness in your loader."],"exampleFix":"// before\n[{ name: 'reviewer' }, { name: 'reviewer' }]\n\n// after\n[{ name: 'project-reviewer' }, { name: 'user-reviewer' }]","handlingStrategy":"validation","validationCode":"function dedupeSkills(skills: Array<{ name: string }> ) {\n  const seen = new Set<string>();\n  const out: typeof skills = [];\n  for (const s of skills) {\n    if (seen.has(s.name)) continue; // or rename\n    seen.add(s.name);\n    out.push(s);\n  }\n  return out;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await agent.addSkills(mergedSkills);\n} catch (error) {\n  if (error instanceof Error && error.message.startsWith('Duplicate ACP skill name')) {\n    const dup = error.message.match(/\"([^\"]+)\"/)?.[1];\n    await agent.addSkills(dedupeSkills(mergedSkills).filter(s => s.name !== dup || keepPreferred(s)));\n  } else {\n    throw error;\n  }\n}","preventionTips":["Deduplicate merged skill collections (project + user + org sources) by name before submission.","Define a precedence rule (e.g. project skills win) and apply it in your loader.","Log or surface silently-dropped duplicates so naming collisions are visible."],"tags":["acp","validation","duplicate","skills"],"backgroundTag":"duplicate-resource","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}