dimondev commited on
Commit
77b2350
·
verified ·
1 Parent(s): 4d7ae49

fix: chat_template, keep tool-call reasoning across later user turns

Browse files

### Summary

Same one-line fix filed on E4B/E2B: an assistant turn that called a tool loses its `reasoning_content` once a later user message exists, invalidating ~27% of the cached prefix on agent loops.

Patched `chat_template.jinja` attached.

```diff
- {%- set thinking_gate = (loop.index0 > ns_turn.last_user_idx) or (preserve_thinking and message.get('tool_calls')) -%}
+ {%- set thinking_gate = (loop.index0 > ns_turn.last_user_idx) or message.get('tool_calls') or preserve_thinking -%}
```

ChatLint stays at 0 errors / gate PASS (this repo already passes the error tier). The change clears a `history_rewrite` that was previously masked by an earlier `tail_marker` warning on the generation prompt, same root cause as E4B, where it surfaces as an error.

```bash
pip install chatlint
chatlint check chat_template.jinja
```

Files changed (1) hide show
  1. chat_template.jinja +1 -1
chat_template.jinja CHANGED
@@ -237,7 +237,7 @@
237
 
238
  {#- Render reasoning/reasoning_content as thinking channel -#}
239
  {%- set thinking_text = message.get('reasoning') or message.get('reasoning_content') -%}
240
- {%- set thinking_gate = (loop.index0 > ns_turn.last_user_idx) or (preserve_thinking and message.get('tool_calls')) -%}
241
  {%- if thinking_text and thinking_gate -%}
242
  {{- '<|channel>thought\n' + thinking_text + '\n<channel|>' -}}
243
  {%- endif -%}
 
237
 
238
  {#- Render reasoning/reasoning_content as thinking channel -#}
239
  {%- set thinking_text = message.get('reasoning') or message.get('reasoning_content') -%}
240
+ {%- set thinking_gate = (loop.index0 > ns_turn.last_user_idx) or message.get('tool_calls') or preserve_thinking -%}
241
  {%- if thinking_text and thinking_gate -%}
242
  {{- '<|channel>thought\n' + thinking_text + '\n<channel|>' -}}
243
  {%- endif -%}