Siestai
Memory ArchitectureSchema

MD Files

Agent and team configuration files — IDENTITY, INSTRUCTIONS, KNOWLEDGE, GOALS, CONTEXT, RULES

The MdFilesService (apps/api/src/memory/md-files.service.ts) manages structured markdown configuration files for agents and teams. These files form the foundation of pipeline/context-assembly|Layer 1 and Layer 2 context.

Agent Files

Each agent has three configuration files:

File KeyPurposeContext Layer
IDENTITYWho the agent is — personality, role, voiceL1 (never truncated)
INSTRUCTIONSHow the agent should behave — rules, constraintsL1 (never truncated)
KNOWLEDGEDomain reference material — facts, proceduresL7 (2000 token budget)

Auto-Provisioning

When ensureAgentMdFiles() is called (during pipeline/context-assembly), it checks if files exist. If not:

  1. Looks up the agent's legacy instructions column
  2. Creates all three files, migrating instructions content to INSTRUCTIONS
  3. Leaves IDENTITY and KNOWLEDGE empty for user customization

This lazy migration ensures backward compatibility with agents created before the MD files system.

Team Files

Each team has three configuration files:

File KeyPurposeContext Layer
GOALSWhat the team is trying to achieveL2
CONTEXTBackground information and shared understandingL2
RULESTeam-specific behavioral constraintsL2

Team files are initialized empty via initTeamMdFiles() when a team is created.

Versioning

Both agent and team files are versioned:

ColumnTypeDescription
versionintegerIncremented on each update (starts at 1)
updated_byvarcharuser or system
updated_attimestampLast modification time

The upsertAgentMdFile() and upsertTeamMdFile() methods handle insert-or-update logic, incrementing the version on each update.

Database Tables

Agent files are stored in agent_md_files:

  • agent_id (FK → agents, CASCADE)
  • file_key (IDENTITY, INSTRUCTIONS, KNOWLEDGE)
  • content (text)
  • Unique constraint on (agent_id, file_key)

Team files are stored in team_md_files:

  • team_id (FK → teams, CASCADE)
  • file_key (GOALS, CONTEXT, RULES)
  • content (text)
  • Unique constraint on (team_id, file_key)

On this page