agentkit.skills¶
Skill — the Facade that composes a prompt + cognition + tools +
memory into one wirable unit, exposed as either skill.as_agent() or
skill.as_tool().
Skills — the Facade between Tool and Agent.
A Skill is a curated bundle of (prompt + cognition + memory) packaged
as a wirable unit. It is what users mean when they say "give me a
researcher" — a specialised agent recipe other agents can either
invoke as a tool (skill.as_tool()) or that a host can materialise
as a runnable Agent (skill.as_agent()).
Skills are immutable value objects. Tools live on the cognition, prompt lives on the skill, memory lives on the skill. Compose at wire-time, reuse across runs.
The framework ships ZERO concrete Skills — apps build their own, the same way they bring their own Tools.
Skill
dataclass
¶
Skill(
name: str,
description: str,
prompt: Prompt | str = "",
cognition: Cognition = SingleCallCognition(),
memory: MemorySource | None = None,
model: str | None = None,
)
A specialised agent recipe — prompt + cognition (+ optional memory + model).
Required
name: stable identifier. Becomes the Tool name when adapted
via as_tool() and the Agent.name when materialised
via as_agent().
description: one-line description. Shown to the outer LLM when
this Skill is adapted as a tool (so it matters for tool
selection); also the default Tool.description unless
overridden at adapter-time.
Optional (sensible defaults so the ergonomic Skill("x", "y")
form works for tests and small examples):
prompt: a Prompt (versioned) OR a plain str (wrapped
into a one-off inline Prompt by the underlying Agent).
Defaults to "" — every real Skill wants a system prompt.
cognition: the turn-taking strategy. Defaults to
SingleCallCognition() — the only cognition the framework
ships that has a no-arg constructor. Real Skills that need
tools wire a ReActCognition(tools=...) explicitly;
multi-agent skills wire CoordinatorCognition(children=...,
policy=...).
memory: a MemorySource the underlying agent's
RequestBuilder auto-grounds against. None (default)
disables the memory hook.
model: default model for the skill. as_agent(model=...) /
as_tool(model=...) may override per-run (e.g. a cheaper
model in tests, a premium model in production).
Design notes¶
Skill is NOT an Agent subclass — it is a Facade recipe. as_agent
constructs a fresh Agent each call; the Skill itself stays
immutable. This makes Skills safely shareable across runs and
threads: nothing per-run lives on the recipe.
The framework ships ZERO concrete Skills (no Researcher, Synthesiser, Critic, …) — applications compose their own from their own prompts, tools, and memory, the same way the framework ships zero Tools.
as_agent
¶
as_agent(*, model: str | None = None) -> Agent
Materialise the Skill as a runnable Agent.
The caller MAY override model per-run (e.g. cheaper model in
tests, premium model in production). Other Skill fields are
pinned at construction and shared by every materialisation.
The underlying Cognition is deep-copied per call.
ReActCognition holds mutable TerminationCondition state
(MaxTurns.turn / Timeout._start) that is reset at the
start of every run — two concurrent runs materialised from the
same shared Skill instance would race on that counter, and one
run's reset() would blow away the other mid-count. Copying
the cognition ties each Agent to its own state graph while
the immutable Skill recipe stays shared.
as_tool
¶
as_tool(
*,
model: str | None = None,
name: str | None = None,
description: str | None = None,
) -> Any
Adapt the Skill into a Tool an outer agent can call via
tool-use.
name / description default from the Skill but can be
overridden if the outer registry needs a different label (e.g.
the same Skill exposed under multiple names in different
registries). model is forwarded to as_agent so the
underlying Agent runs on the override.
Returns a FunctionTool produced by
agentkit.tools.from_agent.as_tool.