Skip to content

API Reference parrot.bots.mixins.identity

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.bots.mixins.identity

View source

IdentityMixin — file-based identity injection + hot reload (FEAT-321).

Opt-in mixin that ties the file-based identity loader (:mod:parrot.bots.prompts.identity) and the composable :data:~parrot.bots.prompts.domain_layers.CAPABILITIES_LAYER together:

  1. Loads {role,goal,capabilities,backstory,rationale}.md from an agent-local identity/ directory and injects any non-empty value as an instance attribute before super().__init__() runs, so the existing kwargs.get(f) or getattr(self, f, None) or DEFAULT resolution chain in AbstractBot.__init__ (abstract.py:432-452) keeps explicit kwargs winning while file values beat class attributes.
  2. Adds CAPABILITIES_LAYER to a per-instance clone of the agent's effective prompt builder via :meth:_configure_identity, called explicitly by the adopting agent after await super().configure() — mirroring the SkillRegistryMixin / AgentMemoryMixin pattern (this mixin does NOT override configure()).
  3. Hot-reloads all five fields on every _build_prompt call (mtime-keyed, near-free) by re-cloning a pristine (never-configured) builder snapshot and swapping it in atomically, carrying over any transient REQUEST-phase layer (e.g. skill_active) present on the outgoing builder.

See sdd/specs/promptbuilder-identity-capability.spec.md §2-3, §7.

Alias CAPABILITIES_LAYER

Re-exported from parrot.bots.prompts.domain_layers.CAPABILITIES_LAYER.

Alias IDENTITY_FILES

Re-exported from parrot.bots.prompts.identity.IDENTITY_FILES.

Alias IdentityFields

Re-exported from parrot.bots.prompts.identity.IdentityFields.

Class IdentityMixin

Opt-in file-based identity injection + hot reload.

Usage::

class MyAgent(IdentityMixin, SomeAgentBase):
    enable_identity = True
    # identity_dir defaults to <module_dir>/identity

    async def configure(self, app=None):
        await super().configure(app)
        await self._configure_identity()

When enable_identity is False (the default) the mixin is fully inert: plain super().__init__() passthrough, no file reads, no layer added, no _build_prompt override effects — non-adopters render a byte-for-byte unchanged prompt.

Parameter Type Default Description
*args Any ()
**kwargs Any {}

Attributes:

Attribute Type Description
enable_identity bool
identity_dir Union[str, Path, None]

Alias PromptBuilder

Re-exported from parrot.bots.prompts.builder.PromptBuilder.

Alias load_identity

Re-exported from parrot.bots.prompts.identity.load_identity.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally