> ## Documentation Index
> Fetch the complete documentation index at: https://braintrust.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Code scorer function must be named handler

export const plans_0 = "Any"

export const deployments_0 = "Braintrust-hosted, Self-hosted"

export const data_plane_version_0 = undefined

export const use_case_0 = "Use case - Code scorers created in the Braintrust UI (playgrounds or experiments)"

<Note>
  **Applies to:**

  * Plan - {plans_0}
  * Deployment - {deployments_0}
  * {data_plane_version_0}
  * {use_case_0}
</Note>

## Summary

**Issue:** Code scorers in the Braintrust UI fail with `ReferenceError: handler is not defined` when the scorer function uses any name other than `handler`.

**Cause:** The UI code scorer runtime requires the function to be named exactly `handler`.

**Resolution:** Rename your scorer function to `handler`.

## Resolution Steps

### For TypeScript code scorers

#### Step 1: Rename function to handler

Update your scorer function name to `handler`:

```javascript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
function handler({
  input,
  output,
  expected,
  metadata,
}: {
  input: any;
  output: any;
  expected: any;
  metadata: Record<string, any>;
}): number | null {
  if (expected === null) return null;
  return output === expected ? 1 : 0;
}
```

### For Python code scorers

#### Step 1: Rename function to handler

Update your scorer function name to `handler`:

```python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
def handler(input, output, expected, metadata):
    if expected is None:
        return None
    return 1 if output == expected else 0

```

## Additional Notes

This naming requirement only applies to code scorers created in the UI. SDK-based scorers can use any function name.
