Skip to content

fix: llm-task tool schema compatibility with llama.cpp + doctor SecretRef crash#35452

Closed
jmzlx wants to merge 1 commit intoopenclaw:mainfrom
jmzlx:fix/llm-task-schema-and-doctor-secretref
Closed

fix: llm-task tool schema compatibility with llama.cpp + doctor SecretRef crash#35452
jmzlx wants to merge 1 commit intoopenclaw:mainfrom
jmzlx:fix/llm-task-schema-and-doctor-secretref

Conversation

@jmzlx
Copy link
Copy Markdown

@jmzlx jmzlx commented Mar 5, 2026

Summary

Two small fixes for local LLM backend compatibility and openclaw doctor reliability.

1. llm-task tool schema — breaks llama.cpp backends (#35443)

The llm-task plugin defines input and schema parameters using Type.Unknown(), which produces JSON Schema without a type field:

{"description": "Optional input payload for the task."}

llama.cpp's OpenAI-compatible endpoint rejects this during JSON schema-to-grammar conversion:

JSON schema conversion failed: Unrecognized schema: {"description":"Optional input payload for the task."}

Fix: Replace Type.Unknown() with Type.Unsafe<unknown>({type: "object", ...}) to emit a concrete type field. Both parameters accept JSON objects in practice (input is a payload, schema is a JSON Schema definition).

Impact: Any agent with llm-task enabled that routes through llama.cpp-based backends (directly or via TensorZero) gets a 400 on every request. Streaming requests return data: [DONE] immediately with no content.

2. openclaw doctor crashes on SecretRef apiKey (#35444)

doctor-memory-search.ts calls .trim() on resolved?.remote?.apiKey, which crashes when the value is a SecretRef object (env var reference) rather than a resolved string:

TypeError: resolved?.remote?.apiKey?.trim is not a function

Fix: Guard with typeof rawApiKey === "string" before calling .trim().

Testing

llm-task fix verified by sending tool definitions with and without type fields to llama-server (Qwen3.5-35B-A3B, Qwen3.5-9B):

  • Without type: 400 error (reproducible)
  • With type: "object": 200 OK

doctor fix verified by confirming the TypeError occurs at the exact line changed, and that the SecretRef is a non-string object at runtime while the gateway resolves it correctly.

Environment tested on

  • OpenClaw 2026.3.2
  • llama.cpp (llama-server, OpenAI-compatible mode)
  • Models: Qwen3.5-35B-A3B, Qwen3.5-9B (both via TensorZero routing)
  • macOS arm64, Node v25.6.1

…tRef crash

Two fixes:

1. llm-task plugin: Type.Unknown() produces JSON Schema without a 'type'
   field, which llama.cpp rejects during schema-to-grammar conversion.
   Replace with Type.Unsafe<unknown>({type: 'object', ...}) to emit
   a concrete type. Fixes openclaw#35443.

2. openclaw doctor: resolved?.remote?.apiKey?.trim() crashes when apiKey
   is a SecretRef object (not a string). Guard with typeof check.
   Fixes openclaw#35444.
@jmzlx jmzlx marked this pull request as draft March 5, 2026 04:42
@jmzlx
Copy link
Copy Markdown
Author

jmzlx commented Mar 5, 2026

Splitting into separate PRs — one per fix.

@jmzlx jmzlx closed this Mar 5, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 5, 2026

Greptile Summary

This PR contains two targeted bug fixes: one addressing JSON Schema compatibility for the llm-task tool with llama.cpp-based backends (replacing Type.Unknown() with Type.Unsafe<unknown>({type: "object"}) to emit a concrete type field), and one preventing a TypeError crash in openclaw doctor when a credential field holds an env-var reference object instead of a resolved string (guarding the .trim() call with a typeof check).

Both fixes are correct and narrowly scoped. The llm-task fix resolves the reported llama.cpp incompatibility (400 error on schema validation). The doctor fix correctly handles SecretRef objects without triggering a TypeError. No regressions are introduced.

Confidence Score: 5/5

  • Both fixes are correct, narrowly scoped, and introduce no regressions.
  • The llm-task schema fix directly addresses the reported llama.cpp incompatibility by adding a required type field to parameter schemas. The doctor fix correctly guards a potentially unsafe method call on an object that may not be a string. Both changes are minimal, targeted, and have no observable side effects. No edge cases are left unhandled.
  • No files require special attention.

Last reviewed commit: 0909f2b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant