Skip to main content

Troubleshooting

Match the symptom or exact message you see to its cause and fix.

This page is indexed by what you observe. If you already have an error code, an exception class, or a process exit code, go to Errors and error codes instead — that page is indexed by error identity.

The session never starts

Symptom: query() yields nothing, or the first await hangs and eventually throws.
CauseHow to confirmFix
The qoderclicn executable is not on PATHThe error is QoderCliProcessError and mentions the executableSet pathToQoderCLIExecutable, or export QODERCLI_PATH
Startup exceeded the load timeoutFailure occurs after a consistent delayRaise loadTimeoutMs; a cold start on a slow disk can exceed the default
No credential was configuredError carries code: 'auth_not_configured'Pass auth; see Authentication
The credential env var is unsetcode: 'auth_access_token_env_var_not_configured' or ..._service_account_...Export the variable the auth helper reads
CLI not found (Java)CliNotFoundExceptionFix the path when qoderCliPath points to an invalid location. On platforms outside the managed set, such as Windows arm64, point to an installed CLI with qoderCliPath or QODERCN_PATH
Managed CLI install failed (Java)RuntimeInstallExceptionSee The managed CLI cannot be installed
Unsafe temp directory (Java)UnsupportedSecureSecretTransportExceptionSee Startup fails with UNSUPPORTED_SECURE_SECRET_TRANSPORT
The credential env var is unset (Java)AuthenticationException with not set in the messageExport the variable before starting the JVM; values passed through putEnvironment() are not used for authentication
Capture stderr while diagnosing startup — it usually names the real problem:
options: {
  stderr: (data) => process.stderr.write(data),
}
Java has no stderr callback. When the CLI exits abnormally, CliProcessException.getStderrTail() returns a bounded, redacted tail of stderr. Collect startup and shutdown events with a diagnostics listener; see Capturing a report worth filing.

An option is rejected before the process starts

The SDK validates several options up front, so a typo fails fast instead of silently disabling a feature. These are thrown synchronously, before QoderCN CLI is started.
MessageCauseFix
securityScan contains unknown option: <key>
security_scan contains unknown option: <key>.
Misspelled switch nameTypeScript uses l1StaticCheck / l2LightweightScan / l3DeepScan; Python uses l1_static_check / l2_lightweight_scan / l3_deep_scan
securityScan.<key> must be a boolean
security_scan.<key> must be a bool.
A string such as 'yes' was passedPass true or false
security_scan must be a dict.A non-mapping value was passed in PythonPass a dict of switches
native mode requires at least one enabled scope; use memory: {} to disable SDK memory
native memory requires at least one enabled scope; use memory={} to disable
Both projectScope and userScope (Python: project_scope and user_scope) set to falseKeep one scope, or use memory: {} (Python: memory={}) to turn memory off
[createSdkMcpServer] Server name must be a non-empty string.Missing or blank nameGive the server a name
[createSdkMcpServer] Tool name must be a non-empty string in server "<server>".A tool was defined without a nameName every tool
[createSdkMcpServer] Tool "<tool>" must have a non-empty description string.Missing descriptionAdd a description; the model relies on it to decide when to call the tool
Java's QoderClient.Builder.build() and SessionOptions.Builder.build() also validate before startup and throw InvalidOptionsException synchronously on failure, for example when auth is missing or both resume and continueSession are set. For the full rules, see SessionOptions.Builder.

The SDK and runtime disagree

Symptom: ProtocolVersionMismatchError or UnsupportedCliCapabilityError (in Java, ProtocolVersionMismatchException or UnsupportedCliCapabilityException). These mean the SDK and QoderCN CLI are from incompatible releases, which normally happens when the runtime is managed separately instead of using the one bundled with the package.
try {
  for await (const message of query({ prompt: 'ping' })) { /* ... */ }
} catch (error) {
  if (error instanceof UnsupportedCliCapabilityError) {
    console.error(`runtime lacks capability: ${error.capability}`);
  }
}
UnsupportedCliCapabilityError.capability names the exact missing feature, which tells you whether to upgrade the runtime or stop using that option. Upgrade QoderCN CLI, or remove the pathToQoderCLIExecutable override so the bundled runtime is used. The Java SDK uses the managed, pinned CLI by default. On a mismatch, check whether qoderCliPath or QODERCN_PATH points to another version; remove it and the SDK falls back to the managed CLI. UnsupportedCliCapabilityException.capabilityState() returns the state the CLI declared for that capability.

The agent never calls my custom tool

Symptom: The tool is registered, the session starts, and the agent solves the task without it. Work through these in order:
  1. Check the fully-qualified name. A tool named greet on a server named my_tools is mcp__my_tools__greet to the model. Allowlists must use the full name.
  2. Check whether an allowlist excludes it. If tools or allowedTools is set and omits the tool, the model never sees it. See Tool naming and allowlists.
  3. Check lazy loading. With MCP lazy loading enabled, tools are not all resident. Mark the ones that must always be available:
tool('greet', 'Say hello', { name: z.string() }, handler, { alwaysLoad: true })
  1. Check the description. The description is the model's only signal for when the tool applies. "Does a thing" gets ignored; state the trigger condition.

The agent stops on a permission it should have

Symptom: Tool calls are denied, or the run stalls waiting for approval that never arrives.
CauseFix
disallowedTools overlaps the tooldisallowedTools takes priority over allowedTools and permissionMode
No approval handler in a non-interactive jobSet a permissionMode that does not require prompts, or supply canUseTool
Both canUseTool and permissionPromptToolName setThey are mutually exclusive; choose one
See Permission Control for the full precedence order.

Model selection times out

Symptom: ModelPolicyTimeoutError. Java does not throw an exception: the diagnostics listener receives an inbound_control_request_failed event whose detail contains error=MODEL_RESOLUTION_TIMEOUT, and the turn's result is handled through ResultMessage.outcome(). resolveModel runs on the critical path of every request and has a 500 ms default budget. A callback that queries a database or an HTTP service will exceed it.
options: {
  resolveModel: async (context) => ({ model: pickModel(context) }), // keep it local
  resolveModelTimeoutMs: 1_500,                                     // or raise the budget
}
Cache the decision outside the callback rather than raising the timeout repeatedly — every millisecond here is added to every turn. In Java, adjust the budget with SessionOptions.Builder.resolveModelTimeoutMs(long); the default is also 500 ms. After a timeout, the turn that requested the model fails and does not fall back to another model.

Memory was not written

Symptom: The agent learned something, the run finished, and nothing was saved. Generation runs in a background agent after the turn completes. A process that exits immediately after the final result message can terminate it mid-write.
// Wait for pending generation before exiting
await q.flushMemory();
In Python without the daemon option, a one-shot query() flushes automatically before it ends input, and QoderSDKClient flushes on disconnect() or when its context exits. A failed automatic flush is only logged; call flush_memory() explicitly when you need to confirm success. With the daemon option, if the CLI declares daemon_async_session_teardown_v1, neither flushes automatically, so a completed close does not mean memory has been written; if you read memory files or start the next session right after closing, use QoderSDKClient and call await client.flush_memory() before closing. See Control memory at runtime. A Java one-shot query can still receive Memory messages after ResultMessage; read the message stream to the end before closing. If flushMemory() / flush_memory() returns and files are still unchanged, inspect the generation result — no_change and skipped are normal outcomes, not failures. See Give agents persistent memory.

A feature I enabled in settings is off

Symptom: A settings file enables something, but the session behaves as if it were disabled. Some query options are authoritative: when provided, they replace the corresponding settings block rather than merging with it, and any switch you omit becomes false. securityScan behaves this way. If settings.json enables l1StaticCheck and the query passes securityScan: { l3DeepScan: true }, then l1StaticCheck is off for that session. Restate every switch you want enabled. See Scan code for security issues.

The agent follows rules I never set

Symptom: The agent obeys conventions that are not in your prompt. Instruction files on the machine running QoderCN CLI are loaded by default, and they can include other files. Log what actually loaded:
options: {
  hooks: {
    InstructionsLoaded: [{ hooks: [async (input) => {
      console.log(input.memory_type, input.file_path, input.load_reason);
      return {};
    }] }],
  },
}
For reproducible runs across hosts, load nothing from disk with settingSources: []. See Customize the system prompt.

Java runtime issues (Java)

The following issues occur only with the Java SDK.

The managed CLI cannot be installed

Symptom: Startup or installRuntime() fails with RuntimeInstallException (error code RUNTIME_INSTALL_FAILED). The SDK does not switch to another CLI version.
CauseFix
The runtime environment cannot reach the Qoder download sitePrewarm the cache while building the image or deploying: java -cp qodercn-agent-sdk-VERSION.jar com.qoder.sdk.RuntimeInstaller (VERSION is the SDK version your application depends on); or ship the pinned archive with the application and point to it with ManagedRuntimeOptions.Builder.localArchive(Path)
A proxy is requiredDownloads choose a proxy from HTTPS_PROXY, ALL_PROXY, and NO_PROXY in the JVM process environment; set them before starting the JVM
Only an enterprise mirror is reachablePoint ManagedRuntimeOptions.Builder.baseUrl(URI) at the mirror; it must serve identical files under the <CLI version>/<file name> layout
Downloads are disabled (DownloadPolicy.DISALLOW or --no-download) and the cache is emptyPrewarm the cache first, or provide a local archive
The archive size or SHA-256 does not match the pinned valueThe mirror or local file is not the one pinned by this SDK release. Replace it with the correct file; the SDK has no option to skip verification
For RuntimeInstaller arguments and all settings, see Prewarming and offline use.

Startup fails with UNSUPPORTED_SECURE_SECRET_TRANSPORT

Symptom: Startup fails with UnsupportedSecureSecretTransportException, and the CLI does not run. The SDK hands authentication and MCP configuration to the CLI through temporary files readable only by the current account. If java.io.tmpdir or any of its parent directories lets other accounts rename or replace entries in it, the SDK refuses to start rather than passing credentials through launch arguments or environment variables. Directories writable only by the current account, and shared directories with the sticky bit set (such as /tmp on Linux), meet the requirement. Fix: point the JVM option -Djava.io.tmpdir=<dir> at a directory writable only by the current account.

A self-specified .cmd CLI is refused on Windows

Symptom: On Windows, startup fails with error code CLI_START_FAILED and a message containing refusing to launch a Windows batch-file CLI. The self-specified CLI is a .cmd or .bat file (for example, the npm-installed qoderclicn.cmd), and the CLI path or launch arguments contain characters that cmd.exe interprets, including parentheses (as in the tool rule Bash(git:*)). cmd.exe may rewrite these arguments, so the SDK refuses to start. Fix: do not specify a CLI path and use the SDK-managed CLI, or point qoderCliPath at an .exe. During automatic lookup, an .exe takes precedence over a .cmd in the same directory.

Use diagnostic events to find shutdown and cleanup problems

When something is left behind after a session closes, the SDK reports it through diagnostic events instead of throwing. For how to register a listener, see Capturing a report worth filing.
Event typeMeaningWhat to do
private_directory_cleanup_failedThe private temporary directory for authentication or MCP configuration was not fully cleaned up. If detail contains credential files may remain, credential files may still be on diskCheck and delete the leftover directory at the path in detail
cli_process_alive_after_closeThe CLI process is still running after shutdown finished; detail lists the termination steps takenConfirm and end the leftover process on the host
process_tree_cleanup_degradedThe current environment cannot fully clean up the CLI process treeChild processes started by the CLI may remain; clean them up at the container or process-group level
capability_downgradedA control request that passed the capability check was rejected as unsupported by the CLI at runtime; capability names the capabilityLater calls to that feature fail with UnsupportedCliCapabilityException. Check whether you specified a different CLI version yourself
mirror_drain_timeoutWrites to external session storage did not finish within the limit at shutdownSome records may not have reached the store. Check the storage backend's latency and raise closeDrainTimeoutMs in SessionMirrorOptions if needed
For the full event list, see DiagnosticEvent.

Capturing a report worth filing

When you need to escalate, collect these before the state is lost:
options: {
  debug: true,
  debugFile: '/tmp/qoder-sdk-debug.ndjson',
  stderr: (data) => process.stderr.write(data),
}
In Java, register the diagnostics listener on the client or on a single session (SessionOptions.Builder.diagnosticsListener); when a session has its own listener, only the session listener is used. managed_runtime_* events for the managed CLI go only to the client listener. Diagnostics are delivered on a best-effort basis and are not a lossless audit log. When the CLI exits abnormally, also record CliProcessException.getExitCode() and getStderrTail(). Include the SDK version, the QoderCN CLI version from the system/init message, the session_id, and the Result subtype with any error_code. Redact credentials, prompts, and source content unless the diagnostic explicitly requires them — see Logging and support.

Next steps