Learnable Agent Architecture and Multi-Role Isolation: A Practical Configuration Guide
A practical guide to designing agents that improve through governed memory, verified skills, and repeatable evaluation rather than unbounded history. It covers a shared execution core, the decision–action–observation loop, layered memory, a validation-gated learning loop, isolated configurations for development, research, and design roles, and a minimal rollout path with safety and operations checks.
1. From Chat Assistants to Agents That Can Keep Running
A typical chat assistant mainly generates a reply from the current input. An agent meant to keep running also has to maintain task state, call tools, keep a filtered set of long-term information, and reuse experience that has already proven useful. The difference is not simply whether the system can run commands. It is whether a full task lifecycle exists.
A practical agent system should be able to answer four questions:
- What is the current task, and what counts as done?
- Which actions will be taken, and what permissions do they require?
- Which information is worth keeping long term, and which is only temporary context?
- How will experience from this run be validated before it is used on future tasks?
“Gets better with use” should not be read as “store more chat history and lengthen the prompt.” Unfiltered history can pollute context, inflate the window, and spread bad experience. Controlled improvement depends on memory governance, skill versioning, and repeatable evaluation.
Always-on operation is not a property that any single architecture guarantees. It depends on process management, scheduling, state persistence, failure recovery, and budget control. A model outage, a tool failure, or missing permissions can stop a task.
2. Base Architecture: One Execution Core, Separate Entry Points
2.1 Reuse the same execution logic across entry points
Terminal interaction, messaging, batch jobs, and editor integrations can share one agent execution core. The entry layer handles identity, message format, and session routing. The core decides and advances the task. The tool layer accesses files, retrieves information, and runs controlled operations.
A generic logical structure looks like this:
Interaction entry↓Identity check and session routing↓Agent execution core├── Context and memory management├── Skill selection and loading├── Tool calls and permission checks└── Task state and execution records↓Format results and return them
A shared core helps avoid different behavior across entry points. The same task submitted from a message channel or a terminal should follow the same tool permissions, memory rules, and completion criteria.
Sharing the core does not mean sharing all state. Multiple roles can use the same execution implementation while keeping separate configuration, credentials, working directories, and memory stores.
2.2 Advance work with a decide–act–observe loop
An agent usually does not emit one answer and stop. It repeats a short cycle:
- Decide the next step from the goal and the evidence already collected.
- Request the tools that step needs.
- Check arguments, permissions, and risk.
- Run the tool and collect the result.
- Add the result to context, then continue or finish.
The pseudocode below only illustrates control flow. The names do not map to any specific product API:
Initialize task stateWhile the task is not complete:Check cancellation, step count, and budgetAssemble the current contextCompress history when neededAsk the model for the next actionIf the action is a tool request:Validate permissions and argumentsRun the controlled toolStore the resultElse:Check whether the answer meets the completion criteriaFinish or continue
The loop needs hard stop conditions: a maximum step count, a time limit, a cost ceiling, and a way for a person to cancel. Without those bounds, the agent can keep searching, rewriting, or retrying and consume resources without progress.
2.3 Design synchronous flows and background jobs separately
Sequential execution is easier to trace and fits tasks with clear dependencies. Work that waits for a long time should not hold an interactive connection open.
A safer pattern is to hand long jobs to a background execution unit and persist the task id, current stage, last successful step, and error information. Whether the job continues after the user disconnects should follow an explicit policy, not the chance that a process stays alive.
3. Layered Memory: Turn History into Reliable Context
3.1 Current-task context
This layer holds the active goal, constraints, tool results, and open items. It should be complete and current, but it usually does not need to live forever.
When context nears its limit, completed stages can be compressed. A summary should at least keep the goal, key decisions, verified conclusions, failure causes, artifact locations, and unfinished work.
Compression is not lossless. For numbers, paths, contract terms, or other critical source evidence, keep the original citation or a structured record instead of relying only on the summary.
3.2 Session history
Session history mainly supports tracing, recovery, and audit. It should not be loaded in full on every model request. Retrieve it by task relevance, time range, and content relevance.
Tool output must stay distinct from system rules. Text from external pages, documents, or files is data to be processed. Appearing in history does not give it permission to change rules or raise its instruction priority.
3.3 Long-term preferences and stable facts
Long-term memory fits confirmed work habits, stable environment constraints, and project rules that remain in force. Examples include “reports must cite sources” or “publish actions require human approval.”
It is a poor place for temporary guesses, unverified identity details, and every conversational aside. Important memories should record source, confirmation time, scope, and validity period, with ways to view, correct, and delete them.
Sensitive credentials should not be stored as ordinary text memory. The agent only needs to know that a class of authorization is required. It should not hold the full secret in the prompt context.
3.4 Skill library
Skills are not factual memory. Facts say what something is. A skill says, under which conditions, how to complete a class of task.
A reusable skill should include:
- Where it applies and where it does not.
- Required inputs, preconditions, and permissions.
- Executable steps and checkpoints.
- How to recover after failure.
- Expected output and acceptance criteria.
- Source, version, and validation status.
A skill does not have to be executable code. It can be a verified operating procedure. What matters is a clear boundary and a checkable result, not a verbatim copy of one successful run.
4. The Learning Loop: Experience Becomes Capability Only After Validation
4.1 Extract candidate skills from execution traces
After a task finishes, the system can review tool calls, corrections, and the final artifact and pull out steps that might be reused.
A data-processing run might yield a candidate flow such as field checks, anomaly location, cleaning and transformation, then result verification. Extraction should drop customer-specific details, temporary directories, and one-off parameters, and keep only structure that can transfer to similar tasks.
Not every task deserves a skill. Tasks that are too simple, not repeatable, or lack acceptance criteria usually need only an execution record.
4.2 Candidate area first, official library second
Auto-generated skills can contain overfitted steps, false premises, or unsafe actions, so they should enter an isolated candidate area first.
Validation can be split into three levels:
Static checks: Look for sensitive data, privilege escalation, obvious conflicts, and preconditions that cannot be met.
Example tests: Run normal, boundary, and failure inputs and check that results match expectations.
Regression evaluation: Compare with existing procedures and confirm the new skill does not reduce correctness, add unnecessary actions, or introduce extra risk.
Without enough test evidence, a skill should stay in a “pending validation” state and require confirmation before use.
4.3 What offline optimization may change, and where it stops
Offline optimization can compare prompt templates, skill descriptions, step order, or candidate strategies. The basic process is to propose candidates, run a fixed test set, and pick the version that is more stable under shared metrics.
That is not the same as training model weights. Weight training also needs a compliant dataset, training resources, and a separate evaluation process. Saving a skill or editing a prompt is not evidence that the model has been trained.
Offline tests also do not guarantee every real scenario. The evaluation set should cover different task types and stay somewhat separate from the examples used for optimization, so the system does not overfit a fixed sample set.
4.4 Pruning skills while keeping a way back
As the skill count grows, duplicate descriptions, conflicting scopes, and stale procedures appear. Maintenance can look at call frequency, success records, last validation time, and overlap with other skills.
Low frequency is not the same as low value. Recovery skills may be called rarely and still matter. A safer order is mark, disable, archive, and only then consider deletion, while keeping version rollback.
5. Isolation for Three Roles
Multiple roles are useful for more than different tone. They separate duties, permissions, source material, and acceptance criteria.
5.1 Software development role
This role works on code changes, diagnosis, and test verification. Its working directory should stay inside the assigned project, and command execution should follow a permission policy.
Long-term memory can hold project conventions and confirmed environment facts. The skill library can hold troubleshooting procedures and pre-release checklists. Acceptance is not “the edit is done.” It also covers test results, the scope of the change, and risks that were not explained.
Actions that touch production configuration, delete data, or publish a release should keep a human approval step.
5.2 Deep research role
This role gathers evidence, compares viewpoints, and produces research conclusions. Its main constraints are source quality and traceable claims.
Each key judgment should separate primary sources, secondary interpretation, and inference, and should record the date and the context in which the material applies. Conflicting evidence should be described as a disagreement, not forced into a single certain conclusion.
A research role generally does not need to modify code or access production credentials. Limiting those permissions shrinks the risk surface created by external content.
5.3 Design role
This role organizes requirements, design rules, copy, and iterative proposals. It can keep confirmed style preferences, size requirements, and acceptance rules, but it should not freeze a temporary choice from one draft as a permanent rule.
Design artifacts should carry a version and a status, such as draft, pending review, or confirmed. External assets should be checked for usage rights and source, so material of unclear origin is not pulled into a formal deliverable.
5.4 Isolation has to exist in the runtime
The three roles should manage at least the following separately:
- Configuration and system instructions.
- Session history and long-term memory.
- Skill catalogs and version records.
- Working directories and artifact storage.
- Access credentials and external message entry points.
- Tool permissions and cost budgets.
- Task logs and scheduler state.
Creating three directories is not full security isolation. If roles run under the same system account with the same file access, they can still read each other’s data. Stronger isolation needs separate runtime identities, a restricted execution environment, and access-control policy.
When roles must collaborate, exchange a filtered task summary and the deliverable, not the entire memory store.
6. Start from Zero: Prove a Minimal Loop, Then Expand
Step 1: Define the task and the acceptance criteria
Start with a narrow, lower-risk task, such as organizing documents in a specified directory and producing a summary with citations. State the allowed access scope, the required output, and the failure conditions.
Step 2: Configure least privilege
Expose only the tools the task needs. Prefer read-only capability first. Add write, execute, and external communication only after behavior is stable.
Permission checks must also run on the tool side. Writing “do not exceed your authority” in the prompt is not enough.
Step 3: Persist state
Save task progress, tool results, and artifact locations, and test recovery after a process interruption. On recovery, distinguish operations that finished, operations that did not, and operations whose result is unknown.
Step 4: Turn on controlled memory
Let only stable facts the user has explicitly confirmed enter long-term memory first. Add automatic candidate extraction later. Provide a way to view and delete memories so bad information does not accumulate.
Step 5: Add candidate skills and validation
Turn effective steps from repeated tasks into candidate skills, validate them on a fixed sample set, then publish. Keep the previous version and a change note on every update.
Step 6: Clone the role template and check isolation
When creating another role, do not copy all credentials and history. Check that the working directory, message routing, access rights, and budget match that role’s duties.
Step 7: Run failure drills
Simulate tool timeouts, network loss, malformed output, duplicate messages, and permission denials. Confirm the system can stop, report the problem, and recover safely.
7. Safety and Operations for Long-Running Agents
An agent that can keep running should not keep acting on its own without limits. Background execution still has to follow trigger conditions, time windows, and an authorization scope.
Side-effecting actions—sending messages, changing data, submitting changes—need protection against duplicate execution. After a timeout, do not assume the operation failed. A retry can send or write the same thing twice.
Logs should record the task id, tool calls, permission decisions, result status, and a necessary artifact summary, without leaking secrets or personal data. Monitoring should cover completion, failure causes, runtime, resource use, and how often a person has to take over.
On the security side, watch for instructions embedded in external content. Retrieval results and tool output must not rewrite system rules or grant the agent new permissions. Tool requests should be checked again outside the model. High-risk actions need explicit approval.
8. How to Tell Whether the System Actually Improved
Evaluate a learnable agent on a reproducible task set, not on a single session.
Keep watching:
- Task completion rate and result correctness.
- How often people correct or take over.
- Time and resource use per task.
- Real benefit after a skill is reused.
- Relevance and error rate of memory retrieval.
- Unauthorized requests, duplicate actions, and failed recoveries.
Hold out tasks that are not used for optimization, and compare against a baseline that does not use the new memory or skills. The learning mechanism is valuable only when correctness, safety, and cost show a verifiable improvement together.
Closing
The point of a learnable agent is not to store history without limit, and not to let the model take more actions on its own. It is a bounded loop: reliable execution produces evidence, filtering turns evidence into memory, repeated experience becomes a skill only after validation, and skills improve through evaluation and version control.
Start with least privilege, explicit acceptance criteria, and a single role, then extend toward multi-role collaboration. Opening every capability at once is less stable. An agent becomes a maintainable working system, rather than a demo assistant, only when learning, isolation, audit, and recovery are designed in together.
