b8634
chat : add Granite 4.0 chat template with correct tool_call role mapping ( #20804 ) chat : add Granite 4.0 chat template with correct tool_call role mapping Introduce LLM_CHAT_TEMPLATE_GRANITE_4_0 alongside the existing Granite 3.x template (renamed LLM_CHAT_TEMPLATE_GRANITE_3_X ). The Granite 4.0 Jinja template uses XML tags and maps the assistant_tool_call role to assistant . Without a matching C++ handler, the fallback path emits the literal role assistant_tool_call which the model does not recognize, breaking tool calling when --jinja is not used. Changes: Rename LLM_CHAT_TEMPLATE_GRANITE to LLM_CHAT_TEMPLATE_GRANITE_3_X (preserves existing 3.x behavior unchanged) Add LLM_CHAT_TEMPLATE_GRANITE_4_0 enum, map entry, and handler Detection: + ( or ) → 4.0, otherwise → 3.x Add production Gr
chat : add Granite 4.0 chat template with correct tool_call role mapping (#20804)
- chat : add Granite 4.0 chat template with correct tool_call role mapping
Introduce LLM_CHAT_TEMPLATE_GRANITE_4_0 alongside the existing Granite 3.x template (renamed LLM_CHAT_TEMPLATE_GRANITE_3_X).
The Granite 4.0 Jinja template uses XML tags and maps the assistant_tool_call role to <|start_of_role|>assistant<|end_of_role|><|tool_call|>. Without a matching C++ handler, the fallback path emits the literal role assistant_tool_call which the model does not recognize, breaking tool calling when --jinja is not used.
Changes:
-
Rename LLM_CHAT_TEMPLATE_GRANITE to LLM_CHAT_TEMPLATE_GRANITE_3_X (preserves existing 3.x behavior unchanged)
-
Add LLM_CHAT_TEMPLATE_GRANITE_4_0 enum, map entry, and handler
-
Detection: <|start_of_role|> + ( or ) → 4.0, otherwise → 3.x
-
Add production Granite 4.0 Jinja template
-
Add tests for both 3.x and 4.0 template paths (C++ and Jinja)
Co-Authored-By: Claude Opus 4.6 [email protected]
-
Code review: follow standard format and use common logic in test-chat-template.cpp
-
Rename custom_conversation variable for extra_conversation to give it a more meaningful name
Co-authored-by: Claude Opus 4.6 [email protected]
macOS/iOS:
-
macOS Apple Silicon (arm64)
-
macOS Intel (x64)
-
iOS XCFramework
Linux:
-
Ubuntu x64 (CPU)
-
Ubuntu arm64 (CPU)
-
Ubuntu s390x (CPU)
-
Ubuntu x64 (Vulkan)
-
Ubuntu arm64 (Vulkan)
-
Ubuntu x64 (ROCm 7.2)
-
Ubuntu x64 (OpenVINO)
Windows:
-
Windows x64 (CPU)
-
Windows arm64 (CPU)
-
Windows x64 (CUDA 12) - CUDA 12.4 DLLs
-
Windows x64 (CUDA 13) - CUDA 13.1 DLLs
-
Windows x64 (Vulkan)
-
Windows x64 (SYCL)
-
Windows x64 (HIP)
openEuler:
-
openEuler x86 (310p)
-
openEuler x86 (910b, ACL Graph)
-
openEuler aarch64 (310p)
-
openEuler aarch64 (910b, ACL Graph)
Sign in to highlight and annotate this article

Conversation starters
Daily AI Digest
Get the top 5 AI stories delivered to your inbox every morning.
More about
claudemodelproduct
Show HN: AI tool to merge people from two photos into one realistic group photo
At a friend's gathering, someone mentioned wanting to add her late father into a family photo. I figured this would be trivial — modern image models are powerful, just send two photos and ask the AI to merge them. She said she'd tried, but the results were weird and unstable, and she didn't know how to describe what she wanted. I went home and tried it myself. With a well-written prompt and two good photos, it works. But real-world use cases aren't two good photos — it's a modern family photo plus a damaged old portrait, or two old photos from different decades. That's when things fall apart. I looked at existing tools. Most showcase merges between clean, well-lit, modern photos. Nobody was solving the hard version: mismatched eras, damaged sources, different poses, different formality lev

I Built an AI Agent That Watches the Market While I Sleep
I have a full-time job and no time to watch the stock market all day. But I still trade — mostly US tech stocks. Last year I made at least three bad decisions because I was too tired or too rushed to think clearly. So I built an AI agent to do the watching for me. The stack: OpenClaw as the agent framework, Exa for information gathering, and Milvus as a personal memory store. Total cost: about $20/month. The NVIDIA Moment On February 26th, NVIDIA reported Q4 earnings — revenue up 65% year-over-year. The stock dropped 5.5%. I didn't find out until the next morning. But when I checked my phone, there was already a message from my agent, sent the previous evening: NVDA earnings analysis: Revenue beat expectations, but the market is skeptical about AI capex sustainability. In similar past situ
Knowledge Map
Connected Articles — Knowledge Graph
This article is connected to other articles through shared AI topics and tags.
More in Products

Full-Stack E-Commerce App - Part 1: Project setup
Hey! Welcome to Part 1 of this series, where we build a complete, production-ready e-commerce app called ShopFlow — from an empty folder all the way to a live site on AWS. By the end of this series, ShopFlow will have: User authentication with JWT tokens A product catalogue with search powered by Elasticsearch A shopping cart (stored in Redis) and a full order system AI features — smart search, a chatbot, and product descriptions generated by AI Real payments via Stripe and PayPal Event-driven order processing with Apache Kafka Deployed on AWS with Kubernetes and a CI/CD pipeline That sounds like a lot — and it is! But we are going to build it one piece at a time . Each part of this series focuses on one thing, explains why we are doing it, and by the end, you have working code. In this fi

Ofcom Pushes Tech Firms to Strengthen Online Safety
More than 70 risk assessments have been legally mandated from 40 of the largest and riskiest sites and apps across the globe. Ofcom has suggested that these assessments are a crucial part of keeping users safe online, and act as guides to putting appropriate safety measures in place. The guardrails are supposed to keep all [ ] The post Ofcom Pushes Tech Firms to Strengthen Online Safety appeared first on DIGIT .



Discussion
Sign in to join the discussion
No comments yet — be the first to share your thoughts!