Applies to:
- Plan:
- Deployment:
hooks.tags to conditionally adjust tracing, logging, or other behavior between CLI and remote eval runs.
hooks.tags to conditionally adjust tracing, logging, or other behavior between CLI and remote eval runs.
BRAINTRUST_CLI=true braintrust eval my_eval.py
import os
from braintrust import Eval, EvalCase
def my_task(input, hooks):
# Add "cli" tag when running via CLI
if os.getenv("BRAINTRUST_CLI") == "true":
if hooks.tags is None:
hooks.tags = ["cli"]
else:
hooks.tags = list(hooks.tags) + ["cli"]
# Your task logic here
return output
Eval(
name="my-eval",
data=lambda: [EvalCase(input="example")],
task=my_task,
scores=[...],
)
def my_task(input, hooks):
is_cli = "cli" in (hooks.tags or [])
if is_cli:
# CLI-specific logic (e.g., verbose logging)
print("Running in CLI context")
else:
# Remote eval logic (e.g., reduced logging)
print("Running in remote eval context")
return output
Was this page helpful?