Install the adapter
Install glm-acp-agent globally or provide an equivalent launcher through command. AML does not download it at
runtime.
Built-in Agent provider
glmAgent()A thin AML profile over the registry-listed glm-acp-agent ACP adapter. AML owns the evaluation, session, Tool bridge, structured result, and cleanup lifecycle; the adapter owns the GLM model loop, its seven coding tools, and Z.AI Coding Plan access.
glmAgent() launches the command configured by command, defaulting to glm-acp-agent. The adapter is a standalone ACP coding agent: it calls the GLM Coding Plan endpoint directly and provides read_file, write_file, list_files, run_command, web_search, web_reader, and image_analysis tools. It is listed in the ACP registry and is community-maintained, not published by Z.ai.
<Agent> AML normalizes model, system instructions, permissions, Tools, and MCP ↓ glm-acp-agent (or your configured command) ↓ GLM Coding Plan endpoint (api.z.ai)Every acquisition receives a private ACP_GLM_SESSION_DIR under AML’s temporary session state, so the adapter’s resumable session files never leak between concurrent evaluations. The state directory is released when the Agent session finishes.
Install the adapter
Install glm-acp-agent globally or provide an equivalent launcher through command. AML does not download it at
runtime.
Provide credentials
Supply a Z.AI API key through apiKey (or Z_AI_API_KEY in env). Coding Plan keys bill against your plan quota,
including the free Lite tier and the free trial period; no pay-as-you-go API balance is required.
Choose a runtime
Run on a trusted host or inside a Sandbox whose image contains Node.js 20+, the adapter, and network access to
api.z.ai.
Install the repository baseline and verify the command from the environment where AML will launch it:
npm install --global glm-acp-agent@1.5.0glm-acp-agent --helpThis version is a repeatable repository baseline, not a guarantee that every newer adapter is compatible. Re-run the live provider path when it changes.
For container execution, the GLM image variant includes this adapter baseline. The default full image includes it too. Local Sandbox still requires glm-acp-agent on the host.
This example uses the public SDK entrypoint and makes the Workspace/Sandbox boundary explicit. A real glm-acp-agent executable must be available in the selected environment. Local Sandbox requires read-write access to start any host process, including the adapter; the instruction not to modify files is therefore advisory. Use an enforcing Sandbox such as Docker when read-only access is a security requirement.
import { Agent, AmlRuntime, Sandbox, Workspace, glmAgent, localSandbox, localWorkspace } from "@aml-jsx/sdk"
const workspace = localWorkspace({ directory: "/absolute/path/to/repository" })const sandbox = localSandbox()const provider = glmAgent({ apiKey: process.env.Z_AI_API_KEY, command: "glm-acp-agent", model: "glm-5.3",})
const result = await new AmlRuntime({ agentProvider: provider,}).evaluate( <Workspace id="glm-review" provider={workspace} load={false} save={false}> <Sandbox provider={sandbox} access="read-write"> <Agent system="Inspect files but do not modify them."> Summarize the repository structure and identify the highest-risk module. </Agent> </Sandbox> </Workspace>)
console.log(result)| Option | Type | Default | Semantics |
|---|---|---|---|
apiKey | string | — | Adds Z_AI_API_KEY and selects the adapter’s z-ai-api-key authentication method. |
command | string | "glm-acp-agent" | ACP executable or launcher. It must be a non-empty, trimmed string without null bytes. |
args | readonly string[] | [] | Appended to the launch command exactly as supplied. Arguments cannot contain null bytes. |
baseUrl | string | — | Writes ACP_GLM_BASE_URL; overrides the default Coding Plan endpoint. |
env | Record<string, string> | {} | Additional launch environment. Use it for adapter-specific configuration. |
maxTokens | number | — | Writes ACP_GLM_MAX_TOKENS; must be a positive integer. |
model | string | — | Provider-level model fallback written as ACP_GLM_MODEL. |
workingDirectory | string | — | Fallback working directory when no Sandbox supplies the effective directory. |
The effective values are resolved as follows:
<Agent model="..." /> overrides the factory model as ACP_GLM_MODEL.system text is prepended to the first prompt inside <SYSTEM> markers; the adapter also loads the project’s AGENTS.md itself.env, then writes its session-owned Z_AI_API_KEY, ACP_GLM_BASE_URL, ACP_GLM_MAX_TOKENS, ACP_GLM_MODEL, and ACP_GLM_SESSION_DIR. Do not rely on overriding those variables through env; they are owned by the AML launch profile.workingDirectory is used when the Agent is not running inside one.apiKey is explicit provider configuration. Otherwise env.Z_AI_API_KEY can satisfy the credential while skipping the advertised authentication method.| AML request | GLM launch behavior | Boundary that still matters |
|---|---|---|
filesystem: "read-write" | permissionPolicy="allow_always" | The host or Sandbox still controls actual process and filesystem authority. |
filesystem: "read-only" | permissionPolicy="allow_once" | The adapter has no read-only tool mode; use an enforcing Sandbox. |
shell: false | No adapter-native mapping is claimed by this profile. | Use a Sandbox that rejects shell execution. |
network: false | No adapter-native mapping is claimed by this profile. | Use a Sandbox or deployment network policy that enforces it. |
command not found or ACP startup failure
Confirm that glm-acp-agent exists in the same host or Sandbox where AML calls spawn(). If you use a custom command, run that exact command with its args outside AML first.
Authentication errors
Create a Coding Plan API key at z.ai and pass it through apiKey or Z_AI_API_KEY. Keys from the general Z.ai Open Platform are a different billing surface and are out of scope for this adapter.
Truncated results
The adapter caps completions at 8192 tokens by default. Raise the ceiling with maxTokens when structured outputs are cut off.
The Agent starts but should not edit or execute
The adapter’s write_file and run_command tools cannot be disabled through ACP. Run the Agent inside a Sandbox whose filesystem access and process policy enforce the restriction.
Configuration is rejected before launch
Remove leading/trailing whitespace and null bytes from strings. maxTokens must be a positive safe integer.
These capabilities use AML’s shared Agent lifecycle and do not require GLM-specific setup: