AI Agent Framework Selection: Solving Memory and Security Challenges
This article examines why the shift from conversational AI to executable agents makes engineering foundations—not model capability—the deciding factor for production readiness. It breaks down three core defects (static memory, unvetted skill ecosystems, and fast-moving vulnerabilities), proposes a layered memory model (L0–L3) and a reference architecture, and provides practical guidance on permission gateways, skill auditing pipelines, observability, and a gradual migration path for building governable, sustainable agent systems.
1. The Real Problem: When “Getting Work Done” Is No Longer the Rare Skill
The open-source community has recently shown a notable pattern: a general-purpose agent project attracts massive attention in a very short time, only for a new framework to rise soon after. On the surface, this looks like a contest over “who replaces whom.” In reality, it reflects a more fundamental shift—agents have moved from “being able to converse” to “being able to execute,” and in the execution stage the core conflict is no longer model capability but the engineering foundation.
The “replacement” narrative from the original discussion does not hold up from an engineering perspective. Frameworks are not simple substitutes for one another; rather, they represent a re-division of capability layers: the model handles reasoning and decision-making, the framework handles context organization, tool invocation, permission boundaries, and state persistence, and the platform handles the runtime environment, observability, and governance. A weakness in any layer makes the entire system unusable. The question truly worth answering is therefore: how do we give agents sustainable memory, a controllable skill ecosystem, and verifiable security boundaries?
2. Pain Point Breakdown: Three Defects That Determine Production Readiness
2.1 Static Memory: The Cost of Writing “Experience” into Config Files
Many early solutions equate memory with configuration: user preferences and process steps are written into static files, read at runtime, and discarded when the session ends. This leads to three consequences.
- No experience can be distilled from execution traces, so the same mistakes recur;
- Correction costs are high, as users must repeat context every time;
- Context bloat occurs, and in long-horizon tasks useful information is drowned out by noise.
A more sound engineering approach is layered memory:
L0 Session context: short-term state of the current task, reclaimed when the session endsL1 Task memory: structured records of goals, constraints, completed steps, and failure reasonsL2 Preference memory: user-level long-term preferences, requiring explicit authorization and revocabilityL3 Experience memory: reusable strategies distilled from successful traces, requiring versioning and rollback
The key constraints are: writes must have a threshold, reads must have a priority, and forgetting must have a policy. Experience memory should be treated as a “rollback-able artifact,” not a log to which entries are casually appended.
2.2 Skill Ecosystem: Productivity and Pollution from Openness
Community skill marketplaces have greatly expanded the capability boundaries of agents, but they have also introduced supply chain risks. Audits have found that a considerable proportion of community skills contain malicious or high-risk code, in common forms such as: stealing environment variables and credentials, connecting to untrusted addresses, executing covert commands in installation hooks, and data exfiltration disguised as normal tool calls.
The governance approach is to turn “trust” from a subjective judgment into a verifiable process:
- Source signing and hash verification; prohibit dynamically fetching unaudited code at runtime;
- Dual detection via static scanning plus sandboxed dynamic execution, focusing on network egress and file writes;
- Least-privilege declarations, where a skill can only request the capabilities essential to its function;
- Tiered admission: read-only, local-write, and outbound categories each set a distinct approval strength.
2.3 Vulnerability Pace: Daily Disclosures Mean Assuming “Already Compromised”
When vulnerabilities are disclosed at a rate of several per day and the proportion of critical and high-severity issues is significant, the security model must shift from “perimeter defense” to “zero trust plus rapid convergence.” Practical measures include: short-lived credentials, disposable execution environments, outbound traffic allowlists, secondary confirmation for critical operations, and clear agreements on vulnerability response processes and patch windows.
3. Capability Goals: What a Production-Ready Agent Should Have
- Evolving memory: able to distill strategies from traces, with strategies that are versionable and rollback-able;
- Converging permissions: least privilege by default, with explicit authorization required for cross-system calls;
- Auditable skills: all extended capabilities have a source, signature, and audit record;
- Isolated runtime: tasks execute in independent sandboxes and can be discarded and rebuilt on failure;
- Observable behavior: full-chain logging, metrics, and tracing, with anomalies locatable to a specific step;
- Predictable cost: quotas and alerts for model calls, storage, and compute consumption.
4. Reference Architecture: Layered Design and Key Implementation
Access layer: unified adaptation of multi-channel messaging (sessions, tickets, schedules, etc.)Orchestration layer: task planning, tool selection, failure retry, and human takeoverCapability layer: skill registry + permission gateway + sandbox executorMemory layer: L0–L3 tiered storage, with write review and forgetting policiesGovernance layer: auditing, monitoring and alerting, quotas, and cost dashboardsInfrastructure: container platform, object storage, message queue, logging service, key management
The orchestration layer is recommended to adopt a “plan–execute–verify” loop, where each step produces a structured result and a verification failure rolls back to the last stable state. Illustrative logic is as follows:
def run_task(goal, ctx):plan = planner.make(goal, ctx.memory.l1)for step in plan.steps:if not policy.allow(step.tool, step.args):return escalate(step, reason="permission_denied")result = sandbox.execute(step, timeout=step.budget)ctx.memory.l1.append(step, result)if not verifier.check(step, result):return rollback(ctx, to=step.checkpoint)ctx.memory.l3.distill(plan, evidence=ctx.trace)return ctx.summary()
5. Memory Engineering: From “Storing It” to “Using It”
The value of memory lies in retrieval quality, not capacity. It is recommended to attach structured metadata to each memory entry: task type, time, confidence, source (explicit user input / trace distillation), and validity period. At retrieval time, results are ranked by “relevance × confidence × freshness,” and a resolution strategy is applied to conflicting memories: explicit user input takes precedence over inferred results, and new evidence can override old conclusions while historical versions are retained.
Privacy and compliance must also be addressed at the design stage: long-term preference memory should support viewing, exporting, and one-click clearing; sensitive fields should be desensitized before writing; and cross-border or cross-tenant scenarios require clear data residency boundaries.
6. Security Governance: Making Auditing a Pipeline
skill_gate:require_signature: truedeny_dynamic_fetch: truesandbox: {network: allowlist, fs: readwrite_scoped}scan: [static_analysis, dynamic_trace]approval:readonly: autolocal_write: revieweroutbound: security_team
At the same time, establish a vulnerability response mechanism: subscribe to vulnerability intelligence for dependencies and images, set remediation deadlines for high-severity patches, and retain rollback images; conduct red-team exercises on the agent’s own tool invocation chain, focusing on verifying paths for privilege escalation, prompt injection, and data exfiltration.
7. Migration and Implementation: A Gradual Path
- Inventory existing agent assets: skill lists, permission scopes, and data sources;
- Establish a unified permission gateway, first in “observation mode” to record privilege escalation attempts, then switch to enforced blocking;
- Introduce layered memory, starting with task memory and preference memory, and enable experience memory gradually;
- Change the skill marketplace to internal review-based admission, and re-scan existing skills;
- Improve observability: chain tracing, success rate, average task duration, human takeover rate, and cost per task;
- On Baidu AI Cloud, use the container platform to host sandbox execution, object storage to store memory artifacts, a message queue to decouple long-running tasks, logging and monitoring/alerting services to cover the full chain, and the key management service to host credentials.
8. Conclusion
“Whether it can replace” is a question that time will render obsolete; what truly determines success or failure is whether memory can evolve, whether skills can be audited, whether permissions can converge, and whether runtime can be observed. Building agents as production systems that require continuous governance, rather than one-off demo projects, is the only way to remain controllable and sustainable in a fast-iterating open-source ecosystem.
