HKUDS/Vibe-Trading · error · TypeError
run_bench_strict requires random_control to be passed explic
Error message
run_bench_strict requires random_control to be passed explicitly (True or False). This rail is borrowed from Soli22de/Bili_Stock's foundation engine after a 9-month audit where every accidental random_control=None call inflated alpha by 3-8 percentage points.
What it means
run_bench_strict takes random_control as a keyword-only parameter with no default; passing None (or omitting it) raises TypeError. This rail exists because accidental random_control=None calls silently inflated alpha by 3-8 percentage points in a past audit, so the API forces an explicit True/False choice.
Source
Thrown at agent/src/factors/bench_runner_strict.py:372
registry: Optional pre-built registry for tests.
Returns:
Dict containing all the keys ``run_bench()`` returns, plus:
- ``random_control`` (bool)
- ``n_random_seeds`` (int)
- ``oos_split`` (str | None)
- ``alpha_t_threshold`` (float)
- ``confirmed_alive`` / ``train_only`` / ``reversed_strict`` /
``noise`` count keys
- Each row carries ``alpha_t_full``, ``alpha_t_train`` (when OOS),
``alpha_t_test`` (when OOS), ``random_ic_mean``.
Raises:
TypeError: If ``random_control`` is omitted (keyword-only, no default).
"""
if random_control is None: # pragma: no cover — guarded by signature
raise TypeError(
"run_bench_strict requires random_control to be passed explicitly "
"(True or False). This rail is borrowed from "
"Soli22de/Bili_Stock's foundation engine after a 9-month audit "
"where every accidental random_control=None call inflated alpha "
"by 3-8 percentage points."
)
start = time.monotonic()
thresholds = thresholds or StrictThresholds()
# Clamp n_random_seeds once and store the actual value used so the
# wire response doesn't lie about the seed count when callers pass 0
# (e.g. from a JSON-config import).
effective_seeds = max(1, int(n_random_seeds))
# Initialise the full schema up-front so even early-error returns
# carry zeroed counters and empty lists — downstream consumers can
# depend on the keys always being present.
entry: dict[str, Any] = {View on GitHub (pinned to 80ffdda44c)
Solutions
- Pass random_control=True or random_control=False explicitly as a keyword
- In wrappers, require the parameter yourself instead of defaulting to None
- Read the docstring: the strictness is intentional (prevents silent benchmark inflation)
Example fix
# before run_bench_strict(registry, **kwargs) # random_control missing # after run_bench_strict(registry, random_control=True, **kwargs)
Defensive patterns
Strategy: type-guard
Type guard
def has_explicit_random_control(kwargs: dict) -> bool:
v = kwargs.get('random_control')
return v is True or v is False Try / catch
try:
run_bench_strict(reg, random_control=True, **kw)
except TypeError as e:
if 'random_control' in str(e): raise ValueError('caller must set random_control') from e
raise Prevention
- Never forward random_control=None from wrappers — make your wrapper require it too
- Add a lint/test that every run_bench_strict call site passes random_control explicitly
When it happens
Trigger: Calling run_bench_strict(...) without random_control=True/False, or explicitly passing random_control=None, or forwarding a None default from a wrapper function.
Common situations: Wrapping run_bench_strict in a convenience function whose own default is None and forwarding it; older call sites written before the parameter became mandatory; test helpers that omit kwargs.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/8e372fefbed23c69.
Report an issue: GitHub.