# world"` before processing, ensuring the inner reasoning is recognized as a single `THINKING` chunk despite arriving in f

> Discover how free-claude-code handles THINKING token parsing with ENABLE_THINKING. Learn to process fragmented reasoning efficiently for better AI code execution.

- Repository: [Ali Khokhar/free-claude-code](https://github.com/Alishahryar1/free-claude-code)
- Tags: internals
- Published: 2026-04-24

---

world"` before processing, ensuring the inner reasoning is recognized as a single `THINKING` chunk despite arriving in fragmented network packets.

## Summary

- **`ThinkTagParser`** in [`parsing/think_tags.py`](https://github.com/Alishahryar1/free-claude-code/blob/main/parsing/think_tags.py) maintains a stateful buffer to extract `"`), the parser waits for the subsequent chunk before yielding a `ContentChunk`, ensuring reasoning content is never fragmented in the SSE output.

### Can I disable thinking tokens for a single API request without changing global settings?

Yes. Include `"thinking": {"enabled": false}` in the request JSON body. The provider checks `request.thinking.enabled` during initialization; when `False`, it discards `ContentType.THINKING` chunks via a `continue` statement in [`providers/openai_compat.py`](https://github.com/Alishahryar1/free-claude-code/blob/main/providers/openai_compat.py) while still parsing them internally for tool detection compatibility.

### Where does the parser logic reside in the free‑claude‑code repository?

The core parsing logic is implemented in the `ThinkTagParser` class located in [`parsing/think_tags.py`](https://github.com/Alishahryar1/free-claude-code/blob/main/parsing/think_tags.py). The integration logic that consumes this parser, evaluates `ENABLE_THINKING`, and emits SSE events resides in [`providers/openai_compat.py`](https://github.com/Alishahryar1/free-claude-code/blob/main/providers/openai_compat.py), specifically within the async streaming loop (lines 87‑110) and the post‑stream flush block (lines 12‑26).

### Why is there both a global `ENABLE_THINKING` flag and a per‑request `thinking.enabled` field?

The environment variable provides a server‑wide default, while the request field allows client‑driven overrides. This dual‑layer approach lets administrators set baseline behavior (e.g., disabled for token cost savings) while permitting specific clients to opt‑in to reasoning visibility without requiring service restarts or separate deployment pipelines.