Skip to content

fix: coerce str prompts to Prompt in exemplar selectors#77

Open
finitearth wants to merge 1 commit into
mainfrom
fix/coerce-str-prompt
Open

fix: coerce str prompts to Prompt in exemplar selectors#77
finitearth wants to merge 1 commit into
mainfrom
fix/coerce-str-prompt

Conversation

@finitearth
Copy link
Copy Markdown
Collaborator

Summary

  • select_exemplars accepted a raw str prompt in practice but passed it straight to task.evaluate, which turned the string into a list of single characters via list(prompts) and later crashed with AttributeError: 'str' object has no attribute 'construct_prompt' (after running predictions on every character first — hence the misleading "fails after many runs").
  • Convert str -> Prompt at the selector boundary in both RandomSelector and RandomSearchSelector, mirroring how optimizers coerce initial_prompts in BaseOptimizer.__init__. task.evaluate stays strict (Prompt-only).
  • Widened the BaseExemplarSelector.select_exemplars type hint to Union[str, Prompt].

Test plan

  • Parametrized the shared selector contract (respects_n_examples, accepts_str_prompt, n_examples_kwarg) over both RandomSelector and RandomSearchSelector
  • Added regression test that a raw str prompt is coerced rather than split into characters
  • Full suite green: 138 passed, 1 skipped

🤖 Generated with Claude Code

@finitearth finitearth requested a review from mo374z as a code owner May 28, 2026 12:06
@github-actions
Copy link
Copy Markdown

Coverage

Tests Skipped Failures Errors Time
141 0 💤 0 ❌ 0 🔥 7.496s ⏱️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants