Add reasoning to LangGraph AI assistant - #6
Open
zonlabs wants to merge 1 commit into
Open
Conversation
Implements visible reasoning text similar to ChatGPT and Cursor, with support
for both Claude extended thinking and custom reasoning for OpenAI/DeepSeek models.
## New Features
### Core Functionality
- **Claude Extended Thinking**: Native support for Claude models with automatic
reasoning extraction from thinking blocks
- **Custom Reasoning**: Two-step reasoning approach for OpenAI, DeepSeek, and
other LLMs that generates explicit step-by-step thinking
- **Plan-and-Execute Reasoning**: Enhanced plan-and-execute graph with reasoning
at planning, execution, and replanning stages
### Files Added
- app/agent/reasoning.py - Custom reasoning nodes (reasoning_node, reasoning_chat_node)
- app/agent/openai_reasoning_graph.py - Ready-to-use graphs for OpenAI models
with reasoning (3 variants: default, explicit, conditional)
- app/agent/plan_and_execute_with_reasoning.py - Plan-execute with reasoning
- test_reasoning.py - Test suite for verifying reasoning functionality
### Files Modified
- app/agent/model.py - Added ChatAnthropic support with extended_thinking enabled
- app/agent/chat.py - Added ThinkingCallbackHandler and thinking block extraction
- pyproject.toml - Added langchain-anthropic>=0.3.19 dependency
### Documentation
- docs/OPENAI_REASONING_GUIDE.md - Complete guide for OpenAI users
- docs/REASONING_GUIDE.md - Comprehensive guide covering all approaches
- docs/REASONING_IMPLEMENTATION_SUMMARY.md - Technical implementation details
## How to Use
### For OpenAI Models
```python
from app.agent.openai_reasoning_graph import openai_reasoning_graph
agent = LangGraphAGUIAgent(
name="mcpAssistant",
graph=openai_reasoning_graph
)
```
### For Claude Models
Just set model to "claude-sonnet-4-5" - extended thinking is automatic
## Benefits
- Transparent AI decision-making process
- Better user trust and understanding
- ChatGPT/Cursor-like reasoning display
- Works with any LLM provider
- Fully integrated with AG-UI protocol
## Testing
Run: python test_reasoning.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements visible reasoning text similar to ChatGPT and Cursor, with support for both Claude extended thinking and custom reasoning for OpenAI/DeepSeek models.
New Features
Core Functionality
Files Added
Files Modified
Documentation
How to Use
For OpenAI Models
For Claude Models
Just set model to "claude-sonnet-4-5" - extended thinking is automatic
Benefits
Testing
Run: python test_reasoning.py