Skip to main content
Applies to:
  • Plan -
  • Deployment -

Summary

Issue: Experiment view displays Prompt: None despite using prompts in the task function. Cause: Prompt detection requires metadata.prompt.id on LLM spans, which only appears when using Braintrust-managed prompts with load_prompt() and prompt.build(). Resolution: Replace hardcoded prompts with Braintrust-managed prompts using the load_prompt() and prompt.build() workflow.

Resolution steps

Step 1: Create a Braintrust prompt

Save your prompt in Braintrust and note the project name and prompt slug.

Step 2: Update your task function

Replace hardcoded prompts with the Braintrust prompt workflow:
import braintrust

client = braintrust.wrap_openai(openai.OpenAI())
prompt = braintrust.load_prompt(project=PROJECT_NAME, slug=PROMPT_SLUG)

def task(input):
    built = prompt.build(input=input)
    response = client.chat.completions.create(**built)
    return response.choices[0].message.content

Eval(
    PROJECT_NAME,
    experiment_name=EXPERIMENT_NAME,
    data=my_data,
    task=task,
    scores=[Levenshtein],
)
The prompt.build() method returns span_info containing metadata.prompt.id, which the wrapped client automatically attaches to LLM spans.

Step 3: Run the experiment

The experiment view will now display the linked prompt instead of None.

Alternative approaches

If you prefer not to use Braintrust prompt management, there is no supported workaround. The experiment UI requires metadata.prompt.id on LLM spans, which only comes from the Braintrust prompt workflow.