{"record":{"id":"d23076345b391645","repo":"calesthio/OpenMontage","slug":"find-similar-set-requires-seed-clip-id","errorCode":null,"errorMessage":"find_similar_set requires 'seed_clip_id'","messagePattern":"find_similar_set requires 'seed_clip_id'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/video/clip_search.py","lineNumber":311,"sourceCode":"        tag_weight=float(inputs.get(\"tag_weight\", 0.3)),\n        motion_min=inputs.get(\"motion_min\"),\n        kind=inputs.get(\"kind\"),\n        exclude_ids=inputs.get(\"exclude_ids\") or [],\n    )\n    return {\n        \"query_text\": query_text,\n        \"results\": [\n            {\"score\": score, \"record\": asdict(rec)}\n            for rec, score in results\n        ],\n    }\n\n\ndef _op_find_similar_set(corp, inputs: dict[str, Any]) -> dict[str, Any]:\n    \"\"\"MMR-based similar-set retrieval from one seed clip.\"\"\"\n    seed = inputs.get(\"seed_clip_id\")\n    if not seed:\n        raise ValueError(\"find_similar_set requires 'seed_clip_id'\")\n\n    results = corp.find_similar_set(\n        seed_clip_id=seed,\n        n=int(inputs.get(\"n\", 5)),\n        diversity=float(inputs.get(\"diversity\", 0.3)),\n        candidate_pool=int(inputs.get(\"candidate_pool\", 30)),\n        exclude_ids=inputs.get(\"exclude_ids\") or [],\n    )\n    return {\n        \"seed_clip_id\": seed,\n        \"results\": [\n            {\"score\": score, \"record\": asdict(rec)}\n            for rec, score in results\n        ],\n    }\n\n\ndef _op_diversify(corp, inputs: dict[str, Any]) -> dict[str, Any]:","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/clip_search.py#L293-L329","documentation":"Raised by _op_find_similar_set when inputs['seed_clip_id'] is missing or falsy. This operation does MMR-based similar-set retrieval anchored on one existing clip, so the seed id is the one required argument.","triggerScenarios":"Calling operation='find_similar_set' with only n/diversity tuning parameters; passing a clip_id under a different key (e.g. 'clip_id'); passing an id variable that is None because a prior lookup failed.","commonSituations":"Chaining operations where the previous step returned no clip and the id variable stays None; key-name drift between get (which uses clip_id) and this op (seed_clip_id); agent tool-call missing the argument.","solutions":["Pass seed_clip_id with a valid id — get one from rank_for_slot results (record fields) or a prior get call","If your variable is named clip_id, map it explicitly: {'seed_clip_id': clip_id}","Guard the chain: skip find_similar_set when the seed lookup found nothing"],"exampleFix":"# before\nresult = clip_search.run(inputs={'operation':'find_similar_set','n':5})\n\n# after\nseed = hits['results'][0]['record']['clip_id']\nresult = clip_search.run(inputs={'operation':'find_similar_set','seed_clip_id':seed,'n':5})","handlingStrategy":"validation","validationCode":"seed = inputs.get('seed_clip_id')\nif not seed:\n    raise ValueError('seed_clip_id required — take one from rank_for_slot results')\ninputs['seed_clip_id'] = seed","typeGuard":"def valid_seed(inputs: dict) -> bool:\n    return bool(inputs.get('seed_clip_id'))","tryCatchPattern":"try:\n    result = clip_search.run(inputs=inputs)\nexcept ValueError as e:\n    if 'seed_clip_id' in str(e):\n        raise SystemExit('find_similar_set needs a seed clip id') from e\n    raise","preventionTips":["Map keys explicitly when chaining ops: clip_id -> seed_clip_id","Skip find_similar_set when the preceding lookup returned found=False","Keep a typed record of clip ids flowing between pipeline steps"],"tags":["clip-search","validation","retrieval"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}