codenib.agent.skills.context
¶
Typed skill-context layer.
Skill executors are factories of the shape create_executor(context) ->
Callable. Historically the context argument was annotated Any in
every skill and the loader selected it via a stringly-typed dict lookup
(_CONTEXT_KEY_FOR_TYPE), so the concrete, well-typed dataclasses defined in
codenib/ops/ (RetrieveContext, RerankContext, TransformContext,
ExpandContext) were erased to Any the moment they crossed into a skill.
This module makes the boundary typed:
- :data:
SkillContext— the union of the four per-op context dataclasses; the type a single-context skill'screate_executorshould accept. - :class:
ComposerContexts— a typed aggregate for multi-context (custom) composer skills (codenib_context,bm25_search) that genuinely need more than one context. Replaces the untypedDict[str, Any]they took. - :data:
CONTEXT_KEY_FOR_TYPE—SkillType -> context-dict keymapping, keyed on the enum (not a bare string), used by the loader to pick the single context a skill receives.
The dataclasses live in ops/ (they carry behaviour like
ensure_agent); this module only re-exports them as a typed surface so the
agent layer can annotate against them without re-importing ops everywhere.
Classes:
| Name | Description |
|---|---|
ComposerContexts |
Typed bundle of per-op contexts for multi-context composer skills. |
ComposerContexts
dataclass
¶
ComposerContexts(
retrieve: "RetrieveContext" | None = None,
expand: "ExpandContext" | None = None,
rerank: "RerankContext" | None = None,
transform: "TransformContext" | None = None,
cross_encoder: "CrossEncoderContext" | None = None,
)
Typed bundle of per-op contexts for multi-context composer skills.
custom skills that compose several stages (search + graph expand,
e.g. codenib_context and the names-mode of bm25_search) need
more than one context. They used to receive the loader's raw
Dict[str, Any] and reach into it with .get("retrieve") /
getattr(..., None). This dataclass gives that bundle a name and a
type; any field may be None when the corresponding index/context was
not built.
Fields mirror the keys produced by
codenib.compiler.skill_context._package_contexts.
Methods:
| Name | Description |
|---|---|
from_mapping |
Build from the loader's |
from_mapping
classmethod
¶
Build from the loader's {key: context} mapping (or None).