fix(runtime): pass model through to the LLM API (+ UTF-8 JSON escaping) #53
Reference in New Issue
Block a user
Delete Branch "fix/llm-model-and-utf8"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
On Tim's machine the Anthropic billing dashboard shows nearly all spend as Sonnet 4.5, even though the Neuron app has Opus 4.8 selected. Root cause is in the el runtime, not config.
llm_call_system(model, system, user)andllm_call(model, prompt)accepted amodelargument and threw it away - they calledllm_chain_call(system, user)with no model, and the legacyANTHROPIC_API_KEYfallback passedNULLtollm_provider_request, so every non-agentic chat was pinned toLLM_DEFAULT_MODEL(claude-sonnet-4-5). The chat response still echoed the selected model as a label, so the UI looked right while the request billed Sonnet.Changes
1. Model passthrough (
el_runtime.c)llm_chain_callnow takesmodel_prefand threads it through.NEURON_LLM_N_MODELoverride and fall back to the requested model otherwise.NULL.2. UTF-8 JSON escaping (
el_runtime.c, separate commit)jb_emit_escapednow validates multi-byte UTF-8 continuation bytes, passes valid sequences through, and escapes orphaned/invalid start bytes as\u00xx. This was found uncommitted in the working tree and is committed here so it is reviewable; it addresses the garbled/binary content we have been seeing in graph nodes.Testing
Not built locally - this checkout has no elc/cc toolchain. Needs a stage build + CI. Suggested check: with no
NEURON_LLM_*providers and a realSOUL_LLM_MODEL=claude-opus-4-8, confirm the request to api.anthropic.com carriesclaude-opus-4-8and bills Opus.Note
Duplicate runtime copies exist (
runtime/legacy/,releases/v1.0.0-…/, andneuron-web/runtime/) and carry the same model bug; out of scope here, flagging for follow-up.🤖 Generated with Claude Code
Approved. Building.