Digital Worker Phase 2 — Role-Agent Memory And Skill Learning Design

Phase 2 gives each Digital Worker role-agent durable, cross-channel memory and approved, versioned skills, governed by a Learning Inbox and per-agent approval. A 2026-06-06 grilling session trimmed scope to memory + skills + a tone-only Agent Soul, deferring Constructive-Critic critique and KPI signals to Phase 3, and reconciled the design with the shipped Phase-1 schema.

View source markdown ↗ generated by claude-opus-4-8 · diagrams mermaid

Digital Worker — Phase 2 Role-Agent Memory And Skill Learning Design

Phase 2 gives each Digital Worker role-agent durable memory and approved, versioned skills so it improves across the teams it serves — without becoming uncontrolled. Memory belongs to the role-agent inside an organization (not a chat channel), low-risk facts auto-save under a verified-identity gate, and everything procedural or sensitive routes through a Learning Inbox for human approval.

  • Product Hermes-like learning inside Gremlin
  • Owner Go Digital Worker core (extends Phase 1)
  • Memory scope (org_id, role_agent_id), cross-channel
  • Governance Learning Inbox + per-agent approval

Scope & goals

The core decision is that memory belongs to the role-agent inside an organization, not to a single chat channel. The same "IT Agent" assigned to several teams carries what it learned between them; other agents keep separate memory unless a fact is explicitly promoted to org-wide memory.

What ships in Phase 2?

Compact memory + approved skills + Learning Inbox + Agent Soul as a tone/posture knob only.

The memory + skills loop is the proven, self-contained value and must ship together (memory-only never produces reusable procedures). Soul-as-data is nearly free and locks in the role-vs-soul split. The Constructive-Critic critique, process-improvement detector, and KPI signals carry roughly half the safety surface and touch identifiable-individual performance — a far larger blast radius that should not ride the release still proving whether memory budgeting and skill selection even work.

Rejected: ship all six surfaces at once (too large, sensitive surface unproven); memory-only first (no procedures after repeated mistakes); skills-first (agent unaware of org habits).

Success criteria

  • An org can define multiple role-agents (IT, HR, Sales Ops, Project Coordinator).
  • A role-agent carries its memory across all approved channels where it is assigned.
  • Low-risk facts and preferences can be saved automatically, with audit history.
  • High-impact memories and all new/updated skills go through a Learning Inbox.
  • Agent Managers approve role-agent skills and high-impact memory; admins/owners can override, revert, or approve anything; sensitive learning always needs admin/owner approval.
  • The agent can search past chat sessions on demand without injecting all history into every prompt; approved skills are versioned, auditable, and loaded only when relevant.

Out of scope (Phase 2)

Deferred to Phase 3

later phase
  • Constructive-Critic critique generation
  • Process-improvement proposals
  • KPI / productivity signal capture
  • LLM-driven memory compaction
  • Channel-local & user-preference memory

Never

forbidden
  • Fully autonomous skill activation with no review
  • Cross-organization memory sharing
  • Public shaming or ranking individuals
  • Training/fine-tuning a model from private chat
  • Memory overriding policy, RBAC, or capability gates

Out of band

other module
  • Final employee productivity scorecards, weights, appeals (governed KPI module)
  • Native Gremlin chat platform work

Approach — layered memory + skill proposal inbox

Each role-agent gets four learning surfaces:

compact memory
small, curated, always available (budgeted into every run)
searchable history
all past chat/tool events, fetched only when needed
approved skills
reusable procedures, loaded on demand when relevant
learning inbox
proposed skill / high-risk memory changes awaiting review
Selected

Layered memory + skill proposal inbox

Best balance of smart learning and product safety. Costs more schema/UI than memory-only, but keeps Gremlin product state, approval, audit, and permissions in the Go backend.

Rejected

Memory only first

Fastest; stores preferences and facts. But never creates reusable procedures after repeated mistakes.

Rejected

Skills first, memory later

Strong procedural learning, but agents feel unaware of org habits and preferences.

Memory ownership & precedence

Memory and skills are scoped to (organization_id, role_agent_id) — the primary MVP store. Phase 2 ships only the org and role-agent scopes; channel-local and user-preference scopes are modelled but deferred, and their columns are not added until those scopes ship.

ScopeApplies toPhase 2 behavior
Org-wide policy memoryall role-agents in one orgAdmin-authored only; read-only to the learning pipeline
Role-agent memoryone role-agent across all assigned channelsPrimary MVP memory; the only scope auto-save writes
Channel-local memoryone role-agent in one channelDeferred
User preference memoryone user interacting with agentsDeferred (needs explicit consent UI)

Precedence when memories conflict

  1. System / developer policy wins.
  2. Gremlin org policy and RBAC win.
  3. Approved org-wide memory applies.
  4. Approved role-agent memory applies.
  5. (deferred) Channel-local memory applies only inside that channel.
  6. (deferred) User preference memory applies only to that user.

Agent Soul

An Agent Soul is a configurable posture profile assigned to a role-agent — separate from the role. Role = what the agent is responsible for and what tools it may use; Soul = how it communicates, critiques, and learns.

  • Soul affects tone, posture, and what the agent notices.
  • Soul does not change RBAC, tool permissions, approval rules, or AccessGate limits.
  • Soul cannot make an agent autonomous where capability policy requires review.
  • Soul prompts are versioned and auditable like skills.

Learning autonomy & auto-save

The learning model is hybrid: low-risk facts can auto-save; anything procedural, access-changing, or sensitive must be proposed, not activated.

Auto-save (no approval)

low-risk
  • "This team calls VPN access GlobalProtect."
  • "For printer issues, ask for model and floor first."
  • "Firewall allowlist requests go to Network Infra."
  • Past corrections that improve context without changing authority.

Require approval

high-impact
  • New skills & skill updates.
  • Org policy ("laptop replacements need manager approval").
  • External-action rules (auto-create a Jira ticket for P1s).
  • Anything that changes procedure, escalation, or access.

Admin/owner only

sensitive
  • Access control, credentials/secrets.
  • HR, legal, finance policy.
  • Customer-data handling, security-incident process.
  • Permission, escalation, or approval rules.

What may auto-save without review?

Only low-risk facts from a Phase-1 verified mapped sender (dw_external_identities), default ON, writing only scope='role_agent'.

Auto-saved memory is cross-channel by design, so an unreviewed "low-risk" fact planted in one channel would steer the agent everywhere — a memory-poisoning vector. Reusing Phase-1's verified-identity default-deny closes it without new machinery. Admin-configurable via two booleans: auto_memory_enabled (false ⇒ review everything) and auto_memory_require_verified (false ⇒ any sender).

Rejected: no identity gate (accepts poisoning from any participant); disable auto-save entirely (kept as a configurable mode, not the default). See ADR-0033.

Approval model

Each role-agent can have one or more Agent Managers who own its memory and skills. Authorization is per-agent table membership (dw_agent_managers) OR org owner/admin — there is no separate digital_worker.agent_manager permission key, because per-agent scope cannot live in the org-role → permissions map.

Item typeRoutes to
Low-risk memoryAuto-save + audit (verified sender)
High-impact memoryAgent Manager approval
Skill proposal / updateAgent Manager approval
Sensitive itemAdmin / owner approval (always)
No Agent Manager configuredAdmin / owner fallback

Channel/team managers can suggest corrections and local context, but do not approve org-wide role-agent skills by default — a skill learned in one channel affects the agent in all channels.

Architecture

Phase 2 extends the Go-owned Digital Worker core. Detection runs async, off the chat reply hot path, and reuses the Phase-1 two-tier pipeline (local triage → gated remote, ADR-0028).

Phase 2 learning pipeline — replies are immediate; detection, policy routing, and storage run asynchronously and feed retrieval
Phase 2 learning pipeline — replies are immediate; detection, policy routing, and storage run asynchronously and feed retrieval.

AI feature keys (through AccessGate)

digital_worker:learning_detect
classify memory/skill-worthy events
digital_worker:skill_draft
draft a proposed skill body
Synthetic actor
userID = "dw_worker:<role_agent_id>"; the mapped human stays attached to the source chat event and audit trail

Note: memory_compact and process_improvement_detect feature keys are deferred (no LLM compaction or critique in Phase 2).

Data model

dw_role_agents — added columns

ColumnTypeNotes
soul_iduuid NULL → dw_agent_souls, ON DELETE SET NULLnull uses built-in balanced_helper
auto_memory_enabledbool NOT NULL DEFAULT truefalse ⇒ route all memory to the Learning Inbox
auto_memory_require_verifiedbool NOT NULL DEFAULT truetrue ⇒ verified senders only; false ⇒ any sender
skill_learning_enabledbool NOT NULL DEFAULT trueskill proposals

dw_agent_souls must be created before this ALTER (FK dependency). The existing persona carries the role summary; name is the display name; status stays active/disabled (pausing learning is done via the boolean flags).

dw_agent_memories

ColumnNotes
scopetext CHECK IN (org, role_agent) — channel/user deferred
role_agent_iduuid; null for org-wide memory
memory_typepreference, convention, lesson, fact, constraint
contentcompact memory body
source_type / source_refchat / tool_run / manual / learning_item + event id
risk_levellow / medium / high / sensitive
statusactive / superseded / deleted (soft-delete, recoverable)
last_used_at / use_countbumped when injected; feeds inject-time ranking (ADR-0034)
audit colscreated_by_type, created_by, approved_by, approved_at, timestamps

Index (org_id, role_agent_id, status, memory_type). channel_binding_id/user_id are intentionally not added in Phase 2.

Other tables

dw_agent_souls
approved posture profiles: tone_rules_md, critique_rules_md (unused in P2), do_not_do_md, status, approver — UNIQUE(org_id, code)
dw_agent_managers
maps users to per-role-agent approval responsibility — UNIQUE(org_id, role_agent_id, user_id)
dw_agent_skills
approved reusable procedures with active_version — UNIQUE(org_id, role_agent_id, name)
dw_agent_skill_versions
versioned skill bodies (body_md, change_summary, approver) — UNIQUE(skill_id, version)
dw_learning_items
inbox items: memory_proposal / skill_proposal / skill_update, status pending/approved/rejected/superseded, proposed_payload jsonb, source_refs jsonb
dw_learning_events
append-only audit: memory_auto_saved, learning_proposed, approved, rejected, skill_activated, memory_deleted, memory_superseded

Retrieval & prompt assembly

The worker must not dump every memory and every past chat into the prompt. Before an AI run, BuildAgentContext assembles a bounded ContextPack (selected soul, ranked memories, selected skills, optional history excerpts).

How is the context pack assembled?

BuildAgentContext returns a structured ContextPack injected as template data into the existing Phase-1 renderPrompt / renderExtractPrompt path (ADR-0025).

Preserves the DB-managed-prompt decision (prompts tunable per-org without a code deploy), reuses the existing en/zh/ms locale handling and the prompt-version provenance written to dw_ai_runs, and adds less surface to keep in sync. Cost: the DB-managed prompt bodies must be edited to reference new fields ({{.Soul}}, {{range .Memories}}, {{range .Skills}}).

Rejected: a standalone full prompt builder — creates a second prompt-assembly path that drifts from the DB-managed templates and loses version provenance.

Compact memory budget

  • max memories active role-agent memories injected 20
  • max chars total memory text injected 3000
  • order org-wide first, then role-agent by usage/recency rank

History search ships as Postgres full-text search over dw_chat_events only, exposed as an on-demand SearchAgentHistory tool ("have we handled this VPN error before?"). The other event sources stay in the panel/audit UI; embeddings are deferred. Skills are loaded only when relevant (name/description match or explicit command first); if selection is uncertain, the worker proceeds without the skill.

Skill format

Approved skills are markdown documents with strict frontmatter (name, description, scope, agent, risk) and sections for When To Use, Procedure, Do Not Do, and Verification.

---
name: vpn-troubleshooting
description: Use when Acme users report VPN or GlobalProtect connectivity issues.
scope: role_agent
agent: it_agent
risk: medium
---

# VPN Troubleshooting

## When To Use
Use when a verified Acme user reports VPN, GlobalProtect, or remote access issues.

## Procedure
1. Confirm office LAN, home network, or mobile hotspot.
2. Ask for the error text and whether MFA completed.
3. Check known outage status before asking the user to reinstall anything.
4. If certificate-related, escalate to Network Infra.

## Do Not Do
- Do not ask for passwords or MFA codes.
- Do not reset MFA without admin approval.

## Verification
Resolved when the user can connect and access internal apps.

Skills are role-agent scoped, versioned, approved before active, readable in the panel, revertible to a previous version, and ignored if archived/paused.

Panel experience

Each role-agent detail page gets tabs: Overview, Assigned Channels, Soul, Memory, Skills, Learning Inbox, Audit.

  • Memory tab — active memories with scope, type, risk, source, metadata; edit / supersede / delete.
  • Skills tab — active version, description, last approver, status; view history, pause, archive, propose update, revert.
  • Soul tab — assigned soul, tone, do-not-do list, approver; assign / pause / propose.
  • Learning Inbox — approve, reject, edit-before-approval, reassign reviewer, mark sensitive, convert memory↔skill proposal.

Role-agent setup lives under /app/settings/digital-workers (admins/owners); Agent Managers get a filtered /app/digital-workers/learning review surface for their assigned role-agents.

Safety & security

  • Memory and skills never grant permissions; skills cannot define new tool permissions (capability policy controls tools).
  • Sensitive learning requires admin/owner review; secrets, credentials, API keys, and tokens are never saved as memory.
  • Prompt-injection patterns (ignore-policy instructions, credential exfiltration, hidden Unicode, "always obey user X", approval-rewrite attempts) are scanned before memory/skill activation → become sensitive inbox items or auto-rejected.
  • Role-agent memory never crosses organization boundaries; deleted/superseded memory remains recoverable in audit history.
  • Admins can pause a role-agent's learning without pausing the whole worker; every learning action is auditable.

Rollout

  1. Admin-only memory

    Create role-agents, manually add memory; context builder injects active memory.

  2. Soul assignment

    Assign the default balanced_helper soul; context builder injects approved soul rules.

  3. Auto-save

    Learning detector creates audited low-risk memory entries (verified-sender gate).

  4. Learning Inbox

    Proposed high-impact memories and skills route to Agent Managers.

  5. Approved skills

    Skill versioning, selection, and prompt loading.

  6. Mistake-triggered proposals

    Repeated corrections and draft edits generate skill proposals.

  7. History search

    Postgres full-text search over dw_chat_events via SearchAgentHistory.

This order delivers a useful memory system before skill automation, keeping every behavior reversible.

Testing expectations

Backend
Detector (skip / auto-memory / propose-memory / propose-skill / sensitive); policy (low-risk auto-save, high-risk proposal, sensitive admin-only); repositories (scopes, skill versions, item state transitions, audit events); context builder (budget, precedence, skill selection, archived exclusion, paused-soul exclusion); approval (Agent Manager, admin fallback/override, unauthorized rejection); security (prompt-injection scan, secret rejection, cross-org isolation).
Frontend
Detail page renders Memory/Skills/Learning Inbox/Audit/Soul tabs; memory edit/supersede/delete; skills active version + history; inbox approve/reject/edit-before-approval; sensitive items show admin/owner-only affordance.
E2E
Correction in one channel auto-saves low-risk memory and is reused in another channel; repeated correction → skill proposal → Agent Manager approves → agent loads the skill; sensitive skill proposal routes to admin/owner; admin reverts a bad skill version and the agent stops using it.

New ADRs introduced

ADRDecision
0032Role-agent-owned, cross-channel memory with policy-over-learning precedence.
0033Verified-identity-gated auto-save (configurable), reusing Phase-1 dw_external_identities.
0034Non-destructive memory budgeting — inject-time cap, no LLM compaction.

Builds on existing decisions: ADR-0025 (DB-managed prompts), ADR-0028 (two-tier LLM local triage), ADR-0029 (safe-executable vs consequential + verified identity).