← Back to PRs

#11141: Fix JSON schema conversion error when using llama.cpp backend

by 9nix00 open 2026-02-07 12:59 View on GitHub →
extensions: llm-task stale
**Subject: Fix JSON schema conversion error when using llama.cpp backend** Hi everyone, I ran into an issue while integrating **openclaw** with **llama.cpp**. Currently, when using llama.cpp as the backend, the interface returns the following error: ``` 400 JSON schema conversion failed: Unrecognized schema: {"description":"Optional input payload for the task."} Unrecognized schema: {"description":"Optional JSON Schema to validate the returned JSON."} ``` I've implemented a fix for this and ran `pnpm test` locally. Everything seems to be passing perfectly (see the logs below): ``` ✓ src/agents/pty-dsr.test.ts (2 tests) 4ms ✓ src/agents/auth-profiles.auth-profile-cooldowns.test.ts (1 test) 4ms ✓ src/cli/nodes-canvas.test.ts (2 tests) 5ms ✓ src/auto-reply/reply/commands-info.test.ts (1 test) 4ms ✓ src/tui/tui.test.ts (2 tests) 5ms ✓ src/channel-web.barrel.test.ts (1 test) 3ms ✓ src/agents/pi-embedded-helpers.image-size-error.test.ts (2 tests) 4ms ✓ src/cli/dns-cli.test.ts (1 test) 81ms ✓ src/agents/tool-policy.conformance.test.ts (2 tests) 3ms ✓ src/commands/doctor-workspace.test.ts (1 test) 5ms ✓ src/cli/wait.test.ts (1 test) 3ms ✓ src/hooks/gmail-watcher.test.ts (1 test) 2ms ✓ src/infra/tls/fingerprint.test.ts (1 test) 2ms Test Files 848 passed (848) Tests 5383 passed (5383) Start at 20:46:09 Duration 233.25s (transform 46.76s, setup 580.61s, import 331.38s, tests 157.63s, environment 74ms) RUN v4.0.18 /Users/wangwenpei/Codes/openclaw ✓ src/gateway/call.test.ts (17 tests) 22ms ✓ src/gateway/server-methods/exec-approval.test.ts (8 tests) 9ms ✓ src/gateway/session-utils.test.ts (28 tests) 10ms ✓ src/gateway/session-utils.fs.test.ts (27 tests) 14ms ✓ src/gateway/chat-attachments.test.ts (12 tests) 25ms ✓ src/gateway/server-chat.agent-events.test.ts (5 tests) 6ms ✓ src/gateway/server-methods/agent.test.ts (3 tests) 18ms ✓ src/gateway/server-methods/agent-timestamp.test.ts (15 tests) 21ms ✓ src/gateway/hooks-mapping.test.ts (7 tests) 19ms ✓ src/gateway/client.test.ts (2 tests) 1794ms ✓ closes on missing ticks 1777ms ✓ src/gateway/hooks.test.ts (5 tests) 6ms ✓ src/gateway/config-reload.test.ts (8 tests) 6ms ✓ src/gateway/server/plugins-http.test.ts (4 tests) 6ms ✓ src/gateway/auth.test.ts (7 tests) 4ms ✓ src/gateway/sessions-patch.test.ts (5 tests) 5ms ✓ src/gateway/server-methods/send.test.ts (5 tests) 16ms ✓ src/gateway/server-methods/usage.test.ts (5 tests) 4ms ✓ src/gateway/server-node-events.test.ts (3 tests) 4ms ✓ src/gateway/boot.test.ts (3 tests) 9ms ✓ src/gateway/server-broadcast.test.ts (1 test) 3ms ✓ src/gateway/protocol/index.test.ts (6 tests) 2ms ✓ src/gateway/ws-log.test.ts (4 tests) 4ms stdout | src/gateway/server.nodes.late-invoke.test.ts [gmail-watcher] gmail watcher stopped ✓ src/gateway/server.nodes.late-invoke.test.ts (2 tests) 2991ms ✓ src/gateway/tools-invoke-http.test.ts (9 tests) 6695ms ✓ src/gateway/server-discovery.test.ts (3 tests) 5ms ✓ src/gateway/server-plugins.test.ts (1 test) 3ms ✓ src/gateway/chat-sanitize.test.ts (4 tests) 2ms ✓ src/gateway/server-methods/logs.test.ts (1 test) 8ms ✓ src/gateway/control-ui.test.ts (1 test) 6ms ✓ src/gateway/server-node-subscriptions.test.ts (2 tests) 4ms ✓ src/gateway/origin-check.test.ts (5 tests) 3ms ✓ src/gateway/assistant-identity.test.ts (3 tests) 3ms ✓ src/gateway/server-utils.test.ts (4 tests) 3ms ✓ src/gateway/net.test.ts (3 tests) 2ms ✓ src/gateway/client.maxpayload.test.ts (1 test) 69ms ✓ src/gateway/server-chat-registry.test.ts (1 test) 2ms Test Files 36 passed (36) Tests 220 passed (220) Start at 20:50:03 Duration 10.52s (transform 13.89s, setup 24.31s, import 10.94s, tests 11.80s, environment 3ms) ``` I’d appreciate it if the maintainers could give it a solid review. To be honest, the fix felt a bit *too* simple, which makes me a little nervous! However, it does solve the problem for us, and so far, we haven't seen any side effects on other providers. Thanks for your time and for this great project! <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adjusts the JSON-schema conversion logic used by the `llm-task` tool when targeting the llama.cpp backend, aiming to avoid emitting schema fragments that llama.cpp rejects (e.g., leaf nodes with only `description`). The change is localized to `extensions/llm-task/src/llm-task-tool.ts`, where schema objects are constructed/normalized before being sent through the gateway to the backend provider. <h3>Confidence Score: 3/5</h3> - This PR is likely safe to merge, but the change risks weakening schema validation or producing non-standard schemas for non-llama backends unless the normalization is carefully scoped and covered by tests. - The fix is small and targeted, and the author reports broad unit test coverage passing. However, without seeing explicit tests for llama.cpp schema translation and without verifying that the modified normalization preserves correct JSON Schema semantics across all tool inputs, there is moderate uncertainty about edge cases (e.g., optional/nullable fields and `$ref`/`anyOf` handling). - extensions/llm-task/src/llm-task-tool.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs