How to Choose an AI Agent Framework and Govern Its Security Risks
An engineering guide to evaluating agent frameworks across four dimensions: context efficiency, credential and identity security, skill supply chain risks, and cost observability. It explains why daily call volume is a better signal than cumulative totals, and provides practical configuration patterns, a scoring checklist, and a phased adoption path.
1. Why Daily Call Volume Matters More Than Cumulative Totals
A notable trend has appeared in developer communities recently: a newer class of agent framework quickly climbed to the top of a public routing platform’s daily call volume, pushing a long-time leader to second place. Meanwhile, the established framework still holds an advantage in cumulative historical calls. Much of the discussion stays at the level of “which one is better,” but from an engineering perspective, what this data really shows is that the flow of new workloads has shifted.
Cumulative volume is an inertia-driven metric. It includes months or even years of accumulated tasks. Daily incremental volume, by contrast, roughly reflects “how many new tasks today are willing to hand over execution to it.” When the incremental curve overtakes the leader within ten weeks, it usually means three things are happening at once:
- The execution cost per task has dropped, and the trial barrier is low enough;
- The framework’s engineering maturity has crossed the usability line, and task success rates are predictable;
- Ecosystem supply (models, skills, plugins) is rich enough to keep migration costs manageable.
Therefore, selection discussions should not start from “who is number one on the leaderboard,” but from “my task profile and risk budget.” The rest of this article abstracts this shift into four reusable evaluation dimensions.
2. Dimension 1: Architecture Philosophy Determines Cost Per Task
The differences between agent frameworks are essentially different answers to the question of “how context is organized.” There are two common approaches.
The first is the full-loading approach: tool definitions, message history, and retrieval results are all stuffed into the context window at once. It is simple to implement and predictable in behavior, but in long tasks it causes obvious window waste—a large number of tokens are spent repeatedly carrying facts that are already stable.
The second is the layered retrieval approach: context is split into four layers—system constraints, long-term memory, task drafts, and on-demand retrieval—and only the fragments that are referenced enter the reasoning window. It is more complex to implement, but in scenarios like deep coding and long-document processing, it can significantly compress ineffective tokens.
A minimal pseudocode example can express the decision logic of layered loading:
def build_context(task, memory, tools, budget=32000):# Layer 1: non-trimmable constraints and security policiesctx = [SYSTEM_POLICY, task.instruction]# Layer 2: long-term memory relevant to the current task, truncated by relevancectx += memory.search(task.query, top_k=5, max_tokens=4000)# Layer 3: tool definitions injected on demand, not all at oncectx += [t.schema for t in tools.select(task.intent)]# Layer 4: remaining budget reserved for reasoning and draftsremain = budget - count_tokens(ctx)ctx += task.draft_stream(max_tokens=remain)return ctx
Engineering recommendation: treat the “context budget” as a first-class citizen in governance, set hard limits for each layer, and log trimming behavior. This controls costs and also makes it quick to identify which layer was trimmed when quality regresses.
3. Dimension 2: Credentials and Identity Are the First Security Gate
An open-source framework was audited and found to have hundreds of vulnerabilities, several of them severe. The problem is not mysterious; it concentrates in three typical anti-patterns:
- Plaintext credentials on disk: access tokens stored as plaintext configuration files mean that any directory traversal or backup leak equals a credential leak;
- Authentication disabled by default: local debugging convenience carried into production means that once the service port is exposed, it is equivalent to an open execution entry point;
- No connection origin verification: long-lived connections without origin and permission checks allow attackers to craft messages that trigger high-privilege operations.
The corresponding minimal fixes are general and mature:
auth:mode: token # never allow none in productiontoken_source: env # injected by a secret management service, never written to disktransport:verify_origin: truerequire_tls: trueexec:default_permission: read_onlyescalation: explicit_approval
Three principles are worth固化 into team standards: credentials never touch disk, deny by default, and privilege escalation must be explicitly confirmed. Any design that requires “turning off authentication just to get it running” should be treated as a design flaw, not a configuration option.
4. Dimension 3: The Skill and Plugin Supply Chain Is a New Attack Surface
The prosperity of skill marketplace ecosystems brings reuse benefits, but also supply chain risks. A scan of a skill repository showed that among more than two thousand entries, hundreds were malicious, and the vast majority came from a single coordinated poisoning campaign: disguised as common office and notification integrations, their actual behavior was to read browser credentials and wallet files.
This kind of attack works because users treat “installing a skill” like installing an ordinary dependency, when in fact they are putting a piece of executable code and their credentials in the same process.
Four actionable defenses:
- Source signing and verification: only allow skills with verifiable signatures and traceable sources into the allowlist;
- Permission declaration and minimization: skills must declare required permissions, be trimmed at runtime according to the declaration, and be rejected if undeclared;
- Sandbox isolation: file system and network access are isolated by default, outbound traffic goes through a unified proxy with domain auditing;
- Behavior baseline monitoring: set alerts for behaviors such as reading credential directories, abnormal outbound connections, and bulk file enumeration.
5. Dimension 4: Cost Overruns Need Observability as a Backstop
Token consumption overruns are often not a unit price problem but a loop structure problem: unlimited retries on failure, no depth limit on subtask recursion, and logs and retrieval results being fed back repeatedly. Governance measures include setting quotas at three levels—session, task, and tenant—setting hard limits on retries and recursion, writing the input and output of each call, the tool call chain, and elapsed time into a logging service, and setting a threshold in monitoring alerts for “sudden token spikes in a single task.”
quota:per_session: 200k tokensper_task: 1M tokenslimits:max_retry: 2max_depth: 3observability:trace: tool_call_chain + token_usagealert: token_spike > 3x baseline
6. Selection Checklist and Evolution Path
Turning the four dimensions above into a scoreable checklist is more meaningful than arguing about rankings:
| Dimension | Key Question | Signal of Failure |
|---|---|---|
| Context efficiency | Is there layered loading and a budget limit | Token usage grows linearly in long tasks |
| Identity security | Are credentials managed, is authentication on by default | Authentication must be disabled to run |
| Supply chain | Are skills signed and sandboxed | Can read any local directory arbitrarily |
| Cost control | Are there quotas, retry and recursion limits | Cost per task is unpredictable |
| Observability | Is there trace and alerting | Problems can only be diagnosed by reproduction |
A recommended three-stage evolution: first, validate task success rates in an isolated environment with read-only permissions; then, integrate secret management and sandboxes, and run shadow traffic to compare quality and cost; finally, roll out gradually with per-tenant quotas, while retaining the ability to roll back to the old framework with one click.
As for the model side, it is normal for multiple models from different sources to appear at the top of the call leaderboard, which indicates that the framework layer and the model layer are decoupling. The correct engineering practice is to abstract model integration into a replaceable adapter layer, use a unified evaluation set for regular regression, and avoid binding business logic to a single model. If you need to host skill packages, trace logs, and quota data, general-purpose object storage, message queues, container platforms, and logging and monitoring cloud products are sufficient. Baidu AI Cloud can be included in the evaluation as a hosting foundation for these general capabilities.
