The Rise of Agents: Architectural Evolution from Passive Response to Continuous Growth
This article examines the structural shift in AI agents from session-bound coding assistants to persistent agents that run as long-lived services, trigger on schedules, and hold two-way conversations through instant messaging. It presents a general engineering view of building an agent that improves over time: a six-layer architecture, long-term memory and user modeling, a self-evolving skill loop, multi-channel access, observability, cost governance, and compliance constraints. All code samples are illustrative pseudocode that explain mechanisms rather than bind to any vendor API.
Over the past year, the form of the AI agent has undergone a structural migration: away from a coding assistant that “lives in the repository” and toward a persistent agent that can reside for the long term, fire on a schedule, and hold two-way conversations through instant messaging tools. Such systems no longer measure themselves solely by the quality of a single answer. Instead, their core metrics are whether memory accumulates, whether skills are reusable, and whether access is secure and controllable. Setting aside specific product attributes, this article discusses from a general engineering perspective how to build an agent that grows: the layered architecture, long-term memory and user modeling, the self-evolution loop for skills, the implementation points and risk boundaries of multi-channel access (such as natively connecting to a personal instant messaging account), and the constraints of observability, cost governance, and compliance. The sample code below is illustrative pseudocode, meant to explain mechanisms rather than bind to any vendor’s interfaces.
1. The Form Shift: Why “Persistent” Changes the Architectural Center of Gravity
A traditional coding agent runs inside a developer’s working session. It reads code, edits files, runs tests, and submits changes; when the task ends, the context is released. Its capability boundary is clear, but it has three natural shortcomings: it cannot execute scheduled tasks while unattended; it cannot proactively push results to the channels where people communicate; and every new session has to rebuild the background from scratch.
A persistent agent moves its runtime location from “inside a session” to “inside a process or service,” and the architectural concerns shift accordingly:
- Lifecycle management: process supervision, health checks, graceful restarts, and task idempotency.
- Externalized state: session context, user profiles, and task queues no longer depend on single-machine memory.
- Event-driven execution: scheduled triggers, message triggers, and pipeline callbacks become first-class citizens.
- Multi-channel I/O: the same agent must serve the command line, an admin console, and instant messaging at the same time.
These four points mean the system cannot be assembled from “a prompt plus plugins.” Scheduling, memory, and permissions have to be built into the execution engine.
2. Layered Architecture: Making “Growth” an Engineerable Module
A six-layer structure is recommended, with explicit contracts between layers:
- Access layer: adapts to the message formats, authentication, and rate limiting of different channels, abstracting everything into InboundMessage/OutboundMessage.
- Orchestration layer: task decomposition, plan generation, tool selection, retry and rollback policies.
- Execution layer: a sandboxed runtime responsible for code execution, file reads and writes, and command invocation, with least privilege as the default.
- Memory layer: four separate stores for short-term context, episodic memory, semantic memory, and user modeling.
- Skill layer: registration, versioning, canary release, and automatic evolution of capabilities.
- Governance layer: audit logs, metrics monitoring, cost quotas, and content safety filtering.
Illustrative interfaces (pseudocode, expressing contracts only):
interface Agent {handle(msg: InboundMessage): Promise<OutboundMessage>runScheduled(job: ScheduledJob): Promise<JobResult>}interface MemoryStore {recall(userId, query, topK): MemoryFragment[]write(userId, fragment, ttl?): void}interface SkillRegistry {resolve(intent): SkillHandle // carries version and canary labelspromote(skillId, from, to): void // triggered by an evaluation gate}
3. Long-Term Memory and User Modeling: The Two Dimensions with the Widest Gap
How “natural” an agent feels depends almost entirely on memory quality. Engineering practice suggests splitting memory into four types and choosing storage for each:
- Short-term context: the current task window, limited in capacity, handled with a sliding window plus summary compression.
- Episodic memory: what happened (why a release failed, the historical contract of an interface), suited to append writes plus a time index.
- Semantic memory: domain knowledge, coding standards, and glossaries, suited to hybrid recall over vector and keyword retrieval.
- User modeling: preferences, common stacks, communication habits, and approval thresholds. This is strongly private data and requires encrypted storage and a design that supports deletion.
The key to user modeling is not “remembering a lot” but “remembering accurately and being correctable.” Three practices are recommended:
- Confidence decay: every preference carries a confidence score and a timestamp, and is down-weighted if it goes unverified for a long time.
- Explicit confirmation: high-impact preferences (such as production change approval) must be confirmed by the user before being written.
- Explainability and erasure: show the user “what I have remembered” and provide one-click forgetting.
On the recall side, hybrid retrieval with reranking is recommended:
candidates = bm25(query) ∪ vector(query)ranked = rerank(candidates, userProfile, recency)context = compress(ranked[:k], budget=token_limit)
4. Skill Self-Evolution: From Manual Maintenance to a Closed Loop
In the traditional approach, skills depend on manual authoring and community maintenance, and the pace of evolution is bounded by human effort. A sustainable approach treats skills as “software assets with evaluations”:
- Collect: record task traces and human corrections to form candidate improvement samples.
- Generate: the agent proposes skill patches or drafts of new skills.
- Evaluate: run pass rate, latency, and cost gates on an offline test set.
- Canary: release to a small traffic share and compare success and rollback rates against the baseline.
- Promote or roll back: raise the version if targets are met, roll back automatically on anomalies.
if pass_rate(new) > pass_rate(base) + δand p95_latency(new) < budgetand cost(new) < cost(base) * 1.1:registry.promote(skill, canary, stable)else:registry.rollback(skill)
This loop turns “the longer you use it, the more accurate it gets” into a measurable result rather than a subjective impression.
5. Multi-Channel Access: Engineering Points for Natively Connecting a Personal Instant Messaging Account
Connecting an agent to a personal instant messaging account (linking by QR code, private and group chats, full coverage of images, video, files, and voice, direct long-polling connections, no public IP required) is highly attractive from a user experience standpoint, but engineering must handle four classes of problems:
- Connection method: long polling or a persistent connection avoids exposing a public entry point and reduces the scan and attack surface; reconnection, heartbeats, and backpressure must be implemented.
- Message normalization: text, transcribed voice, images, and files are unified into standard events carrying source, time, and conversation ID.
- Permissions and boundaries: in group chats, distinguish “being named” from “listening to everything,” default to least privilege, and require a second confirmation for out-of-scope instructions.
- Compliance and privacy: define data retention policies, redaction rules, and a user withdrawal mechanism, and avoid writing sensitive conversations into long-term memory.
onMessage(msg):if msg.type == "voice": text = asr(msg.audio)if msg.chat.type == "group" and not mentioned(msg): returnif requiresApproval(msg.intent): return askConfirm(msg)reply = agent.handle(normalize(msg))send(msg.chat, reply)
6. Observability and Cost Governance
Persistent operation means continuous billing and continuous risk, so governance must be built in:
- Metrics: task success rate, human takeover rate, average number of turns, rollback rate, and token consumption per task.
- Logs: structured audit records capturing summaries of tool call arguments and the results of permission decisions.
- Quotas: rate and budget caps per user, session, and channel, degrading to “summary only” when exceeded.
- Model routing: split traffic between lightweight and high-performance models by task complexity, balancing quality and cost.
7. Rollout Advice and Common Anti-Patterns
The recommended rollout order: start with a read-only assistant (queries, summaries, inspections), then add controlled write operations (requiring approval), and only then open up scheduling and proactive pushes. Anti-patterns include: stuffing all history into the context until cost spirals out of control; shipping skills with no evaluation; long-term memory with no TTL or deletion mechanism; and responding to everything in group chats by default, which creates noise.
Conclusion
The competitiveness of a persistent agent lies not in the brilliance of a single answer but in four engineering capabilities: correctable memory, evaluable skills, controllable access, and predictable cost. Making these built-in mechanisms is what turns an agent from a tool into a partner for sustained collaboration. On platforms such as Baidu AI Cloud, the layers above can be built on general-purpose capabilities like container platforms, message queues, object storage, log services, and monitoring and alerting, without binding to any proprietary interface.
