@@ -535,37 +535,46 @@ def model(*args, **kwargs):
535535 features (caching, evaluation, registry, serialization) work unchanged.
536536
537537 Args:
538- context_args: List of parameter names that come from context (for unpacked mode)
539- context_type: Explicit ContextBase subclass to use with context_args mode
538+ context_type: Optional ContextBase subclass used only to validate/coerce
539+ `FromContext[...]` inputs against an existing nominal context shape
540540 cacheable: Enable caching of results (default: False)
541541 volatile: Mark as volatile (default: False)
542542 log_level: Logging verbosity (default: logging.DEBUG)
543543 validate_result: Validate return type (default: True)
544544 verbose: Verbose logging output (default: True)
545545 evaluator: Custom evaluator (default: None)
546546
547- Two Context Modes:
547+ Primary authoring model:
548+ Mark runtime/contextual inputs explicitly with `FromContext[...]`.
549+ Ordinary unmarked parameters are regular bound inputs and are never
550+ read implicitly from the runtime context.
548551
549- Mode 1 - Explicit context parameter:
550- Function has a 'context' parameter annotated with a ContextBase subclass.
552+ @Flow.model
553+ def load_prices(
554+ source: str,
555+ start_date: FromContext[date],
556+ end_date: FromContext[date],
557+ ) -> GenericResult[pl.DataFrame]:
558+ return GenericResult(value=query_db(source, start_date, end_date))
559+
560+ Advanced interop path:
561+ Functions may still declare an explicit context parameter annotated
562+ with a ContextBase subclass.
551563
552564 @Flow.model
553565 def load_prices(context: DateRangeContext, source: str) -> GenericResult[pl.DataFrame]:
554566 return GenericResult(value=query_db(source, context.start_date, context.end_date))
555567
556- Mode 2 - Unpacked context_args:
557- Context fields are unpacked into function parameters.
558-
559- @Flow.model(context_args=["start_date", "end_date"], context_type=DateRangeContext)
560- def load_prices(start_date: date, end_date: date, source: str) -> GenericResult[pl.DataFrame]:
561- return GenericResult(value=query_db(source, start_date, end_date))
562-
563568 Dependencies:
564- Any non-context parameter can be bound either to a literal value or
569+ Any ordinary parameter can be bound either to a literal value or
565570 to another CallableModel. When a CallableModel is supplied, the
566571 generated model treats it as an upstream dependency and resolves it
567572 with the current context before calling the underlying function.
568573
574+ `FromContext[...]` parameters are different: they may be satisfied by
575+ runtime context, construction-time contextual defaults, or function
576+ defaults, but not by CallableModel values.
577+
569578 Usage:
570579 # Create model instances
571580 loader = load_prices(source="prod_db")
0 commit comments