Engineering and Governing AI Agent Harnesses: Identity, Closed-Source Components, and Supply Chain Security

    This article explains why the agent harness—the runtime framework around a model that handles context assembly, tool invocation, access control, retries, logging, and cost tracking—often determines whether an agent succeeds in production. It breaks down three related concerns into general engineering topics: identity verification that turns anonymous tools into accountable actors through subject identity, authorization, and audit layers; ways to establish trust in closed-source core components using contract-based interfaces, sandboxing, policy-as-code, observability, and replaceability; and supply chain defenses against source code leaks, including credential rotation, dependency integrity checks, runtime allowlist validation, and treating external content as untrusted data. It closes with a phased rollout approach: isolation first, least privilege next, and full-chain auditing last, validated through red team exercises.

    1. What We Actually Mean by a Harness

    As agents move from demos to production systems, success is often determined not by the model itself but by the runtime framework wrapped around it—commonly called the harness. The harness handles context assembly, tool invocation, access control, error retries, log tracing, and cost accounting. Put simply, the model provides reasoning capability, while the harness determines whether that capability can be released safely, reliably, and with a clear audit trail.

    Three hot topics in the original discussion—identity verification requirements, closed-source core components, and source code leaks—may look like three separate incidents. They are really three facets of the same question: as agent autonomy increases, how should responsibility boundaries and trust boundaries be redrawn? Each is abstracted below into a general technical issue with engineering recommendations.

    2. Identity Verification: From “Account” to “Accountable Actor”

    Requiring users to complete identity verification essentially upgrades an agent from an “anonymous tool” to an “accountable actor.” The reason is that agents can execute actions on their own: they read and write files, issue network requests, and call external APIs. Once side effects occur, after-the-fact tracing must be able to pinpoint the responsible party.

    A three-layer design is recommended:

    1. Subject identity layer: callers connect using service accounts or workload identities, with credentials centrally managed by a key management service. Hardcoding is prohibited.
    2. Authorization layer: follow the principle of least privilege, issuing short-lived tokens at task granularity to avoid the spread of long-lived, high-privilege credentials.
    3. Audit layer: write “who, at what time, in what context, triggered which tool, and produced what side effect” into an immutable logging service.

    Illustrative policy configuration:

    1. agent_policy:
    2. identity: workload_service_account
    3. token_ttl_seconds: 900
    4. tools:
    5. - name: file_read
    6. scope: ["/workspace/**"]
    7. - name: http_request
    8. allow_domains: ["internal-api.example"]
    9. audit:
    10. sink: log_service
    11. fields: [actor, session_id, tool, args_hash, result_code]

    It is worth stressing that identity verification and privacy are not opposed: verification results can retain only an irreversible identifier, while raw data stays local or in a private environment, accessed through tiered authorization.

    3. Closed-Source Core Components: Building Trust on Verifiable Engineering Constraints

    Not opening the source code of core components is usually driven by three considerations: security, commercial interests, and compliance. For users, the real risk is not “not being able to see the code” but “not being able to verify behavior.” External constraints should therefore replace trust in internal implementation:

    • Contract-based interfaces: stable interface definitions and versioning policies constrain behavior so inputs and outputs are predictable.
    • Sandbox isolation: agents run in container- or function-level isolated environments with restricted file systems, network egress, and system calls.
    • Policy as code: permissions and compliance rules are managed as declarative configuration and included in version control and review processes.
    • Observability: collect call chains, tool latency, failure rates, and token consumption, and set thresholds through monitoring and alerting.
    • Replaceability: decouple the model layer from the tool layer architecturally, preserving the ability to switch between inference services and avoid single-point lock-in.

    4. Source Code Leaks and Supply Chain Protection

    Once the runtime framework’s source code leaks, risk concentrates in three places: exposure of internal interfaces and default credentials, reverse engineering of permission validation logic, and theft of prompts and business rules—leading to targeted prompt injection and unauthorized calls. The protection approach is consistent with conventional supply chain security:

    1. Rotate credentials that may be affected, and audit default configurations and debug interfaces.
    2. Lock dependency versions and verify integrity, using only artifacts from trusted sources.
    3. Validate tool arguments against an allowlist at runtime; never concatenate unvalidated external text.
    1. def safe_invoke(tool, args, policy):
    2. if tool not in policy.allowed_tools:
    3. raise PermissionError(tool)
    4. if not policy.schema(tool).validate(args):
    5. raise ValueError("invalid args")
    6. return policy.sandbox.run(tool, args, timeout_s=30)
    1. Treat external content as untrusted data, separated from the instruction channel, to reduce the success rate of prompt injection.

    5. Implementation Recommendations

    In the Baidu AI Cloud environment, the above capabilities can be implemented by combining general cloud product categories: a container platform hosts the sandbox, object storage holds build artifacts, a message queue decouples tasks, logging and monitoring with alerting handle auditing and early warning, and a key management service manages credentials. The recommended order is isolation first, then least privilege, then full-chain auditing, with red team exercises used for continuous validation.