﻿# Sacred captured functions: explicit arguments take precedence over recorded configuration

Trace Sacred captured-function parameters through explicit call arguments, configuration injection and Python defaults before treating a saved config as every effective runtime value.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-sacred-captured-function-argument-precedence/
Language: en

## Find the value consumed by the captured function

An experiment records a configured evaluation batch size, but an internal helper always calls the evaluator with a different explicit value. The researcher changes the configuration and observes no corresponding behavior change. The [Sacred configuration guide](https://sacred.readthedocs.io/en/latest/configuration.html) defines parameter precedence for captured functions. Explicit positional or keyword arguments take priority, configuration fills missing arguments, and function defaults come afterward. This order explains why a valid recorded configuration may not determine every invocation's effective arguments.

## Separate function defaults from experiment defaults

A Python default on a captured function is not necessarily the experiment's default when configuration supplies that parameter. Reading the signature alone can therefore suggest the wrong baseline. Inspect the composed configuration and the actual call together. If the function is also used outside the experiment, describe which path the comparison concerns. A standalone unit call and a captured invocation can legitimately receive different values without either execution being broken.

## Make namespaces part of the explanation

Captured functions can use prefixes to access a configuration subtree. Similar keys in a dataset section and an evaluator section are not interchangeable merely because their final names match. Trace the selected namespace before changing a parameter that appears relevant in a large configuration. A refactor that moves a helper into another prefix can alter the source of its injected arguments. Preserve that binding change when interpreting differences between experiment revisions.

## Record effective exceptions to the configuration

The [experiment overview](https://sacred.readthedocs.io/en/latest/experiment.html) explains captured functions and the run object, while [collected information](https://sacred.readthedocs.io/en/latest/collected_information.html) describes the final configuration sent to observers. A deliberate explicit override can be useful for a diagnostic slice. Record its purpose and effective value with the result instead of assuming the configuration file alone fully describes that special call. This keeps an exceptional evaluation from being mistaken for the normal configured path.

## Test precedence with distinguishable values

Use different recognizable values for the explicit argument, configuration entry and Python default. Observe which value reaches the helper under each intended call path, then repeat after a namespace change. Related material explains [controlled experimental inputs](/journal/data-guide-curriculum-order-controlled-replay/) and [explicit schema contracts](/journal/data-guide-frictionless-table-schema/). The test establishes argument provenance. It does not establish that the chosen batch policy or evaluation procedure is scientifically appropriate; those remain separate design decisions once the effective value is known.
