Layi Docs
Agents & Memory
Supervisor planners, specialist executors, and the memory fabric that keeps them grounded
🧑✈️ Roles & responsibilities
Layi agents follow a strict hierarchy. Supervisors plan and coordinate work, while specialists execute scoped tasks with tightly-controlled tools. Every org also receives an Org-Manager agent that audits performance and schedules improvements.
🏢 Org-Manager agent (default supervisor)
The Org-Manager agent is instantiated for every tenant at signup. It is separate from the human Org Manager portal and cannot create users or API keys. Instead, it manages every other agent on behalf of the organization.
- Orchestration: delegates multi-agent workloads, invokes the Planner-Agent for new missions, and keeps the mission graph accurate.
- Performance review: inspects run confidence scores daily, requests procedural learning when quality drops, and approves/declines refinements.
- Notifications & escalations: monitors incidents, tool expirations, and escalations, then pages humans via notification tools.
- Document & data management: keeps organizational documents up-to-date via doc manager APIs and confirms edits with humans.
- Reporting: produces configurable org, department, and tool reports for stakeholders.
- Quality assurance: fixes broken context, corrects logical errors, and blocks hallucinations before they spread.
- Guardrails & security: enforces and overrides guardrails, ensuring confidential data stays scoped correctly.
- Tool credential management: assigns or revokes tools based on department policy (e.g., HR agents never see finance tools).
- Agent control: disables misbehaving agents or terminates tasks when safety requires it.
- Monitoring & audits: watches progress, token usage, and audit logs; coordinates with humans for billing and continuous improvement.
The Org-Manager agent is highly autonomous but transparent: every action is logged, and it always routes human communication through approved channels.
📆 Task schedules & working hours
Agents execute tasks immediately, on a defined schedule, or in response to events. Temporal schedules, cron-like policies, and Working Hours windows keep them aligned with business calendars.
- One-time missions: Trigger ad-hoc jobs (e.g., “audit the Q4 finance inbox”) that run to completion once and archive their artifacts.
- Recurring schedules: Configure cron/interval rules such as “send weekly org report every Monday at 16:00” or “refresh vendor rosters on the first business day of the month.”
- Working hours: Define local business hours (e.g., 5am–7pm PT). Agents automatically “wake up,” place calls, send emails, and pause outreach outside of compliant windows.
- Event-driven: Hook schedules to signals (new ticket, stale invoice, voice hotline ring) so planners launch only when the upstream system emits an event.
- Overrides & skips: Operators can pause, skip the next run, or reschedule within the dashboard without editing YAML/cron syntax.
Each scheduled run captures the plan, timezone metadata, and any SLA clocks so auditors know why the agent acted at that moment.
📋 Default sub-agent roster
Every organization is provisioned with a canonical roster so critical guardrails exist before custom agents are deployed. The Agent Creator workflow enforces the roster even when LLM output is incomplete.
⚙️ Agent lifecycle
Agents are defined in Cassandra, hydrated at runtime, and continuously improved through nightly learning passes.
- Create: Org supplies prompts/templates or invokes Agent Creator. Configs are stored with UUID agent_ids inside the registry.
- Bootstrap: Org-Manager workflow registers mandatory sub-agents and schedules nightly audits.
- Execute: Supervisors load configs, attach tools, and run inside Temporal workflows with procedural memory streaming events.
- Observe: Each step records observability summaries, plan diffs, and procedural events for replay.
- Improve: Nightly learners read reward payloads, update procedural memory, and optionally request agent refinements.
🧠 Memory attachments
Agents keep context separated into specialized stores so retrieval stays fast and auditable.
📣 Org-Manager integration
`_record_post_run_feedback` persists reward payloads and decides whether to trigger the Org-Manager follow-up workflow. Reasons include severity, low scores, or verification failures. Temporal schedules also ensure nightly health checks per org.
- Bootstrap: `OrgManagerCreatorWorkflow` seeds default configs, writes PostgreSQL mappings, and caches schedule guards.
- Follow-ups: `trigger_org_manager_followup` launches ad-hoc audits with memoized reasons and reward snapshots.
- Reports: Org-Manager agents persist findings to procedural + episodic memory and can escalate incidents via MCP tools.
- Refinement loop: Recommendations can automatically update agent configs via `request_agent_refinement` helpers.
📞 Voice & chat surfaces
Every agent can expose a chat endpoint, SDK token, and LiveKit-powered voice line. Org Manager owns the routing table so you can assign a dedicated phone number per agent or share an org-wide entry point that dynamically forwards to the right specialist.