calesthio/OpenMontage · error · ValueError

find_similar_set requires 'seed_clip_id'

Error message

find_similar_set requires 'seed_clip_id'

What it means

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.

Source

Thrown at tools/video/clip_search.py:311

        tag_weight=float(inputs.get("tag_weight", 0.3)),
        motion_min=inputs.get("motion_min"),
        kind=inputs.get("kind"),
        exclude_ids=inputs.get("exclude_ids") or [],
    )
    return {
        "query_text": query_text,
        "results": [
            {"score": score, "record": asdict(rec)}
            for rec, score in results
        ],
    }


def _op_find_similar_set(corp, inputs: dict[str, Any]) -> dict[str, Any]:
    """MMR-based similar-set retrieval from one seed clip."""
    seed = inputs.get("seed_clip_id")
    if not seed:
        raise ValueError("find_similar_set requires 'seed_clip_id'")

    results = corp.find_similar_set(
        seed_clip_id=seed,
        n=int(inputs.get("n", 5)),
        diversity=float(inputs.get("diversity", 0.3)),
        candidate_pool=int(inputs.get("candidate_pool", 30)),
        exclude_ids=inputs.get("exclude_ids") or [],
    )
    return {
        "seed_clip_id": seed,
        "results": [
            {"score": score, "record": asdict(rec)}
            for rec, score in results
        ],
    }


def _op_diversify(corp, inputs: dict[str, Any]) -> dict[str, Any]:

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Pass seed_clip_id with a valid id — get one from rank_for_slot results (record fields) or a prior get call
  2. If your variable is named clip_id, map it explicitly: {'seed_clip_id': clip_id}
  3. Guard the chain: skip find_similar_set when the seed lookup found nothing

Example fix

# before
result = clip_search.run(inputs={'operation':'find_similar_set','n':5})

# after
seed = hits['results'][0]['record']['clip_id']
result = clip_search.run(inputs={'operation':'find_similar_set','seed_clip_id':seed,'n':5})
Defensive patterns

Strategy: validation

Validate before calling

seed = inputs.get('seed_clip_id')
if not seed:
    raise ValueError('seed_clip_id required — take one from rank_for_slot results')
inputs['seed_clip_id'] = seed

Type guard

def valid_seed(inputs: dict) -> bool:
    return bool(inputs.get('seed_clip_id'))

Try / catch

try:
    result = clip_search.run(inputs=inputs)
except ValueError as e:
    if 'seed_clip_id' in str(e):
        raise SystemExit('find_similar_set needs a seed clip id') from e
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/d23076345b391645. Report an issue: GitHub.