calesthio/OpenMontage · error · ValueError
rank_for_slot requires 'query_text'
Error message
rank_for_slot requires 'query_text'
What it means
Raised by _op_rank_for_slot in clip_search when inputs['query_text'] is missing, empty, or whitespace-only after .strip(). rank_for_slot is the text-embedding retrieval operation, so a query is mandatory before embed_texts is called.
Source
Thrown at tools/video/clip_search.py:286
"per_kind": per_kind,
"mean_motion_score": float(np.mean(motion_scores)) if motion_scores else 0.0,
"mean_duration": float(np.mean(durations)) if durations else 0.0,
}
def _op_rank_for_slot(corp, inputs: dict[str, Any]) -> dict[str, Any]:
"""Embed `query_text` and return top-k clips by fused similarity.
This is the agent's main retrieval move. The returned list is
ordered best-first and every entry carries a score so the agent
can decide whether the match is strong enough (>= 0.25 is a rough
"acceptable" threshold for CLIP ViT-B/32).
"""
from lib.clip_embedder import embed_texts
query_text = inputs.get("query_text", "").strip()
if not query_text:
raise ValueError("rank_for_slot requires 'query_text'")
q_vec = embed_texts([query_text])[0]
results = corp.rank_by_text(
query_embedding=q_vec,
k=int(inputs.get("k", 10)),
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
],
}View on GitHub (pinned to 95e1c3d0ab)
Solutions
- Supply a non-empty query_text describing the desired footage (subject, motion, setting)
- Strip/validate the query at your call site before invoking the tool
- If the query comes from another step, fail fast there with a clear message rather than relying on this error
Example fix
# before
result = clip_search.run(inputs={'operation':'rank_for_slot','k':10})
# after
result = clip_search.run(inputs={'operation':'rank_for_slot','query_text':'slow motion ocean waves at dusk','k':10}) Defensive patterns
Strategy: validation
Validate before calling
query = (inputs.get('query_text') or '').strip()
if not query:
raise ValueError('query_text is required for rank_for_slot')
inputs['query_text'] = query Type guard
def valid_rank_query(inputs: dict) -> bool:
return bool(isinstance(inputs.get('query_text'), str) and inputs['query_text'].strip()) Try / catch
try:
result = clip_search.run(inputs=inputs)
except ValueError as e:
if "rank_for_slot requires" in str(e):
raise SystemExit('provide a text query describing the footage') from e
raise Prevention
- Strip and require non-empty queries at the UI/agent boundary
- Give agents an explicit error message when transcription/caption extraction yields blank text
- Describe subject + motion + setting in queries for better CLIP matches
When it happens
Trigger: Calling the clip_search tool with operation='rank_for_slot' and no query_text; passing query_text='' or ' '; a caller building inputs dynamically where the query variable is None (inputs.get returns '' default only when key absent).
Common situations: An LLM agent omitting the query argument in a tool call; upstream text extraction returning empty (e.g. blank caption or failed transcription feeding the query); form/UI validation gap.
Related errors
- find_similar_set requires 'seed_clip_id'
- diversify requires 'candidate_ids'
- get requires 'clip_id'
- ${res.status} ${url}
- fetch failed ${r.status}: ${url}
AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15).
Data as JSON: /api/errors/3a0fb850f4853915.
Report an issue: GitHub.