# Thinking & Reasoning

Modern AI models use internal "chain-of-thought" reasoning to decompose complex problems, analyze edge cases, and verify hypotheses before formulating their final response.

AIsh.li surfaces this reasoning process in real time through an elegant, collapsible **Thought Process** interface, providing complete transparency and auditability without cluttering the chat experience.

## What is Model Thinking?

When tackling challenging tasks—such as writing complex code, solving multi-step mathematical puzzles, or evaluating multi-condition business policies—advanced models (such as Gemini 3.1 Pro) perform intermediate deductions.

Instead of hiding these steps behind a black box or outputting pages of raw internal monologue, reasoning models generate a dedicated reasoning block:

```
[thinking]
1. The user asks whether Novello is closer to Barolo or Alba.
2. Looking up coordinates: Novello (44.58° N, 7.92° E), Barolo (44.61° N, 7.94° E).
3. Distance Novello to Barolo: ~3.5 km.
4. Distance Novello to Alba: ~15 km.
5. Conclusion: Barolo is significantly closer.
[/thinking]

Barolo is much closer to Novello, located just 3.5 km away (about a 6-minute drive), whereas Alba is approximately 15 km away.
```

## Real-Time Streaming & Interactive UI

AIsh.li's streaming protocol detects thought tokens (such as `[thinking]` and `<think>`) on the fly as they arrive over Server-Sent Events (SSE):

1. **Active Streaming**: While the model is actively thinking, the thought drawer automatically expands with a subtle glowing pulse, allowing you to follow its analytical reasoning as it happens.
2. **Auto-Collapse**: Once the model completes its thought process and begins generating the final conversational response, the thought drawer cleanly collapses.
3. **Expand on Demand**: Users and developers can click the **Thought process** button at any time to inspect the full chain of thought.
4. **Copy Markdown**: Clicking the Copy button on a message copies the clean answer, with an option to inspect raw thoughts.

## Why Transparent Thinking Matters

- **Auditability**: Verify _why_ an agent made a particular recommendation or chose a specific tool.
- **Error Detection**: Spot reasoning oversights or flawed assumptions early in the reasoning chain before taking real-world actions.
- **Clean User Experience**: End-users receive a concise, polished response without wading through intermediate scratchpad notes.
- **Debugging Agent Prompts**: Observe how the model interprets system instructions and constraints to refine prompts faster.

## Try It in Practice

1. Open [Chat with Google Gemini](/chat/agent/demo/gemini).
2. Submit a reasoning riddle or puzzle, for example:
   - **Math & Trick Logic**:
     > _"A bat and ball cost \$1.10 in total. The bat costs \$1.00 more than the ball. How much does the ball cost?"_
   - **Constraint Satisfaction**:
     > _"A farmer has a wolf, a goat, and a cabbage. He needs to cross a river in a boat that can only carry him and one item at a time. If left alone, the wolf eats the goat, and the goat eats the cabbage. How can he cross safely?"_
3. Watch the **Thought process** accordion expand in real time as the agent works through the intermediate deduction step-by-step!
