def for_search(state, outcome):
    """Format evaluation result for consumption by search."""

    if state == "error":
        return {"error": True}
    if state == "ok":
        loss = outcome["loss"]
        var = outcome.get("var", None)
        return {"loss": loss, "var": var}