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.
Symptom:
Capture
Java has no stderr callback. When the CLI exits abnormally,
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.
Java's
Symptom:
Symptom: The tool is registered, the session starts, and the agent solves the task without it.
Work through these in order:
Symptom: Tool calls are denied, or the run stalls waiting for approval that never arrives.
See Permission Control for the full precedence order.
Symptom:
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
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
In Python without the
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
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:
For reproducible runs across hosts, load nothing from disk with
The following issues occur only with the Java SDK.
Symptom: Startup or
For
Symptom: Startup fails with
Symptom: On Windows, startup fails with error code
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.
For the full event list, see
When you need to escalate, collect these before the state is lost:
In Java, register the diagnostics listener on the client or on a single session (
The session never starts
Symptom: query() yields nothing, or the first await hangs and eventually throws.
| Cause | How to confirm | Fix |
|---|---|---|
The qoderclicn executable is not on PATH | The error is QoderCliProcessError and mentions the executable | Set pathToQoderCLIExecutable, or export QODERCLI_PATH |
| Startup exceeded the load timeout | Failure occurs after a consistent delay | Raise loadTimeoutMs; a cold start on a slow disk can exceed the default |
| No credential was configured | Error carries code: 'auth_not_configured' | Pass auth; see Authentication |
| The credential env var is unset | code: 'auth_access_token_env_var_not_configured' or ..._service_account_... | Export the variable the auth helper reads |
| CLI not found (Java) | CliNotFoundException | Fix 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) | RuntimeInstallException | See The managed CLI cannot be installed |
| Unsafe temp directory (Java) | UnsupportedSecureSecretTransportException | See Startup fails with UNSUPPORTED_SECURE_SECRET_TRANSPORT |
| The credential env var is unset (Java) | AuthenticationException with not set in the message | Export the variable before starting the JVM; values passed through putEnvironment() are not used for authentication |
stderr while diagnosing startup — it usually names the real problem:
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.
| Message | Cause | Fix |
|---|---|---|
securityScan contains unknown option: <key>security_scan contains unknown option: <key>. | Misspelled switch name | TypeScript uses l1StaticCheck / l2LightweightScan / l3DeepScan; Python uses l1_static_check / l2_lightweight_scan / l3_deep_scan |
securityScan.<key> must be a booleansecurity_scan.<key> must be a bool. | A string such as 'yes' was passed | Pass true or false |
security_scan must be a dict. | A non-mapping value was passed in Python | Pass a dict of switches |
native mode requires at least one enabled scope; use memory: {} to disable SDK memorynative memory requires at least one enabled scope; use memory={} to disable | Both projectScope and userScope (Python: project_scope and user_scope) set to false | Keep one scope, or use memory: {} (Python: memory={}) to turn memory off |
[createSdkMcpServer] Server name must be a non-empty string. | Missing or blank name | Give the server a name |
[createSdkMcpServer] Tool name must be a non-empty string in server "<server>". | A tool was defined without a name | Name every tool |
[createSdkMcpServer] Tool "<tool>" must have a non-empty description string. | Missing description | Add a description; the model relies on it to decide when to call the tool |
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.
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:
- Check the fully-qualified name. A tool named
greeton a server namedmy_toolsismcp__my_tools__greetto the model. Allowlists must use the full name. - Check whether an allowlist excludes it. If
toolsorallowedToolsis set and omits the tool, the model never sees it. See Tool naming and allowlists. - Check lazy loading. With MCP lazy loading enabled, tools are not all resident. Mark the ones that must always be available:
- 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.
| Cause | Fix |
|---|---|
disallowedTools overlaps the tool | disallowedTools takes priority over allowedTools and permissionMode |
| No approval handler in a non-interactive job | Set a permissionMode that does not require prompts, or supply canUseTool |
Both canUseTool and permissionPromptToolName set | They are mutually exclusive; choose one |
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.
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.
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:
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.
| Cause | Fix |
|---|---|
| The runtime environment cannot reach the Qoder download site | Prewarm 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 required | Downloads 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 reachable | Point 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 empty | Prewarm the cache first, or provide a local archive |
| The archive size or SHA-256 does not match the pinned value | The 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 |
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 type | Meaning | What to do |
|---|---|---|
private_directory_cleanup_failed | The 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 disk | Check and delete the leftover directory at the path in detail |
cli_process_alive_after_close | The CLI process is still running after shutdown finished; detail lists the termination steps taken | Confirm and end the leftover process on the host |
process_tree_cleanup_degraded | The current environment cannot fully clean up the CLI process tree | Child processes started by the CLI may remain; clean them up at the container or process-group level |
capability_downgraded | A control request that passed the capability check was rejected as unsupported by the CLI at runtime; capability names the capability | Later calls to that feature fail with UnsupportedCliCapabilityException. Check whether you specified a different CLI version yourself |
mirror_drain_timeout | Writes to external session storage did not finish within the limit at shutdown | Some records may not have reached the store. Check the storage backend's latency and raise closeDrainTimeoutMs in SessionMirrorOptions if needed |
DiagnosticEvent.
Capturing a report worth filing
When you need to escalate, collect these before the state is lost:
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
- Errors and error codes — look up a specific code, exception class, or exit code
- Authentication — configure credentials and handle expiry
- How it works — understand startup and the agent loop