pynydus.agents.letta.spawner¶
Letta spawner connector. Spec §10.3.
Parses a Letta agent export directory, database dump, or .af AgentFile:
*.af (AgentFile) -> Letta’s official portable agent format (AgentFileSchema)
agent_state.json -> memory blocks (persona, human, system) + agent config
archival_memory.json / archival/ -> long-term archival memory records
tools/ -> Python tool definitions -> skill records
system_prompt.md -> system prompt -> memory record
.letta/ marker directory (optional)
Also supports reading from a Letta SQLite database file (agent.db) as a fallback when structured JSON exports are not available.
Module Contents¶
Classes¶
Parse a Letta agent export directory, database, or AgentFile. |
Functions¶
Read neutral LLM / embedding fields from an AgentFile |
|
Load agent_state.json from a file dict. |
|
Extract text from a memory block value (string or dict with value/text). |
|
Extract text from a message. |
|
Convert a Python module name to a display name (e.g., search_web -> search web). |
Data¶
Glob patterns the pipeline uses to read source files from disk. |
API¶
- pynydus.agents.letta.spawner._AGENT_STATE_FILES¶
(‘agent_state.json’,)
- pynydus.agents.letta.spawner._ARCHIVAL_FILES¶
(‘archival_memory.json’,)
- pynydus.agents.letta.spawner._SYSTEM_PROMPT_FILES¶
(‘system_prompt.md’, ‘system_prompt.txt’)
- pynydus.agents.letta.spawner._DB_FILES¶
(‘agent.db’,)
- pynydus.agents.letta.spawner._BLOCK_LABEL_MAP: dict[str, pynydus.common.enums.MemoryLabel]¶
None
- pynydus.agents.letta.spawner.FILE_PATTERNS¶
[’.json’, ‘.md’, ‘.txt’, ‘.yaml’, ‘.yml’, ‘.af’, ‘tools/.py’, ‘archival/.txt’, ‘archival/*.m…
Glob patterns the pipeline uses to read source files from disk.
- pynydus.agents.letta.spawner._extract_af_llm_embedding(agent: dict) tuple[str | None, int | None, str | None]¶
Read neutral LLM / embedding fields from an AgentFile
agentdict.
- class pynydus.agents.letta.spawner.LettaSpawner¶
Bases:
pynydus.api.protocols.SpawnerParse a Letta agent export directory, database, or AgentFile.
- FILE_PATTERNS¶
None
- parse(files: dict[str, str]) pynydus.api.raw_types.ParseResult¶
Parse pre-redacted file contents into raw skills and memory.
Args: files:
filename -> UTF-8 content(already redacted). DB-mode may use synthetic keys such as_db_tables.json.Returns: Skills, memory, and MCP configs.
- parse_db(db_path: pathlib.Path, supplemental_files: dict[str, str] | None = None) pynydus.api.raw_types.ParseResult¶
Parse directly from a Letta SQLite database.
This is the special case for DB-mode extraction. The pipeline calls this instead of
parse()when the source is a.dbfile.Args: db_path: Path to the Letta
agent.dbSQLite file. supplemental_files: Additional text files to parse alongside the DB.Returns: Skills and memory extracted from database tables.
- _try_parse_agent_file(files: dict[str, str]) pynydus.api.raw_types.ParseResult | None¶
Try to parse a .af AgentFile from the files dict.
Handles the real AgentFileSchema with top-level
agents,blocks,tools,mcp_servers,skills,metadata.
- static _parse_af_blocks(data: dict, memories: list[pynydus.api.raw_types.RawMemory], af_name: str | None) None¶
Parse top-level
blockslist from AgentFileSchema.
- static _parse_af_system_prompt(agent: dict, memories: list[pynydus.api.raw_types.RawMemory], af_name: str | None) None¶
Parse
systemfield from the agent dict.
- static _parse_af_tools(data: dict, skills: list[pynydus.api.raw_types.RawSkill], af_name: str | None) None¶
Parse top-level
toolslist.Only custom tools (with
source_code) become skill records. Built-in Letta tools (letta_core, letta_builtin, letta_sleeptime_core) havesource_code: nulland are skipped.
- static _parse_af_skills(data: dict, skills: list[pynydus.api.raw_types.RawSkill], af_name: str | None) None¶
Parse top-level
skillslist (SkillSchema objects).Each skill has
name, optionalfilesdict (must includeSKILL.md), and optionalsource_url.
- static _parse_af_tool_rules(agent: dict, memories: list[pynydus.api.raw_types.RawMemory], af_name: str | None) None¶
Parse
tool_rulesfrom the agent dict as FLOW memory.
- static _parse_af_messages(agent: dict, memories: list[pynydus.api.raw_types.RawMemory], af_name: str | None) None¶
Parse
messagesfrom agent dict as STATE memory.Message
contentis a list of{type, text}objects in AgentFileSchema, not a plain string.
- static _parse_af_env_vars(agent: dict, memories: list[pynydus.api.raw_types.RawMemory], af_name: str | None) None¶
Parse
tool_exec_environment_variablesfrom agent dict.After redaction these become SECRET placeholders. We store them as CONTEXT memory so the pipeline secret scan can replace the raw values with
{{SECRET_NNN}}placeholders.
- static _parse_af_mcp_servers(data: dict, mcp_configs: dict[str, dict]) None¶
Parse top-level
mcp_serverslist.
- _parse_skills(files: dict[str, str]) list[pynydus.api.raw_types.RawSkill]¶
Parse skills from file contents dict.
- _parse_memories(files: dict[str, str]) list[pynydus.api.raw_types.RawMemory]¶
Parse memories from agent state, system prompt, and archival memory.
- static _get_tables(conn: sqlite3.Connection) set[str]¶
- pynydus.agents.letta.spawner._load_agent_state_from_files(files: dict[str, str]) dict | None¶
Load agent_state.json from a file dict.
- pynydus.agents.letta.spawner._extract_block_text(block_value: object) str¶
Extract text from a memory block value (string or dict with value/text).