soka 0.0.2 โ†’ 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11429e43f0b571946c8e67e96b18d137b3f5228298ad28b97e0fbd20c798df62
4
- data.tar.gz: 870c1fbbda1a2d2031e7210043d54d9cad3e0fcafc699c1c5d36fb99ec2bcae4
3
+ metadata.gz: b99b5c66b841d01fa4ac0955e3924d5057787027827bdd9794094304ad218fae
4
+ data.tar.gz: 4343a63fd6057865f9fd03ac7de05e3a12ca1e2ef6e8b4fe2b35e4c088e7cb1a
5
5
  SHA512:
6
- metadata.gz: 849434f90de4f1fdadc31cf9df1652731bf85cfbb9e097098e644c3b779b6e7efe53bea79c98208b3333b3b654c7fab9ebc5ccc3a0540aedc65b2f1ee7d10676
7
- data.tar.gz: b1f88b544efdfbc9f2883c9fee969132eb4b9efa17ccc6f38aca4940892b1b5558b7c872e890c5b8fe06178fb0aaeac2a30d023e72095fa9768482909404fcce
6
+ metadata.gz: 633bf8b6bece348f71a53ca68229b710cbb0437372eaac0ca8d7b3e1a83baea6f9a31ed3d4cc68267f6cafcd6bbb5aefc28327212cacbc74d1d15437c0faf5ec
7
+ data.tar.gz: 3c5e8939f02d9ad9804e053b57ae22227c00662a4a57d35b4685e63a980534412c81441d75a46939d94e288b122084f7f612022c95e20ed506c1162114c25d1b
data/CHANGELOG.md CHANGED
@@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.0.3] - 2025-08-03
11
+
12
+ ### Features
13
+ - feat: add think_in feature for multilingual reasoning (2e587f3)
14
+ - feat: add custom instructions support for agents (95c2689)
15
+ - feat: add think_in languages example (505ef60)
16
+
17
+ ### Code Refactoring
18
+ - refactor: optimize think_in feature and improve security (4bcd026)
19
+ - refactor: remove confidence score from result and related components (057cf93)
20
+ - refactor: extract response parsing and result building into separate concerns (0d62388)
21
+
22
+ ### Tests
23
+ - test: fix RSpec violations and restructure tests (17c1af7)
24
+ - test: add RSpec test for think_in feature (759c113)
25
+ - test: remove test_helpers module and update test files (2e587f3)
26
+
27
+ ### Documentation
28
+ - docs: add documentation for custom instructions and multilingual thinking features (151e8e3)
29
+ - docs: add Rails integration documentation (41815e6)
30
+
31
+ ### Chores
32
+ - chore(release): add changelog extraction step for GitHub release (cbb65d8)
33
+ - chore: add .rspec_status to gitignore (0a0ebb3)
34
+
10
35
  ## [0.0.2] - 2025-08-01
11
36
 
12
37
  ### Features
data/CLAUDE.md CHANGED
@@ -1,201 +1,349 @@
1
1
  # Soka - Ruby ReAct Agent Framework
2
2
 
3
- ## Project Overview
3
+ ## ๐ŸŽฏ What is Soka?
4
4
 
5
- Soka is a Ruby AI Agent framework based on the ReAct (Reasoning and Acting) pattern. It supports multiple AI providers (Gemini Studio, OpenAI, Anthropic) and provides an object-oriented tool system and intelligent memory management.
5
+ Soka is a Ruby framework for building AI agents using the ReAct (Reasoning and Acting) pattern. It enables your Ruby applications to leverage AI capabilities through a clean, object-oriented interface.
6
6
 
7
- ## Core Architecture
7
+ ### Key Features
8
+ - **Multi-Provider Support**: Works with Gemini, OpenAI, and Anthropic out of the box
9
+ - **ReAct Pattern**: Implements structured reasoning with Thought โ†’ Action โ†’ Observation โ†’ Final Answer flow
10
+ - **Tool System**: Define custom tools that agents can use to interact with your application
11
+ - **Memory Management**: Built-in conversation and thought process tracking
12
+ - **Minimal Dependencies**: Only requires `faraday` and `zeitwerk` - no heavy frameworks
13
+
14
+ ## ๐Ÿš€ Quick Start
15
+
16
+ ```ruby
17
+ class MyAgent < Soka::Agent
18
+ provider :gemini
19
+ model 'gemini-2.5-flash-lite'
20
+
21
+ tool :calculator, 'Performs math calculations' do
22
+ def call(expression:)
23
+ # Your tool logic here
24
+ end
25
+ end
26
+ end
27
+
28
+ agent = MyAgent.new
29
+ result = agent.run("Calculate 123 * 456")
30
+ puts result.final_answer
31
+ ```
32
+
33
+ ## ๐Ÿ“ Project Structure
8
34
 
9
- ### Directory Structure
10
35
  ```
11
36
  soka/
12
- โ”œโ”€โ”€ lib/
13
- โ”‚ โ”œโ”€โ”€ soka.rb # Main entry point with Zeitwerk autoloading
14
- โ”‚ โ””โ”€โ”€ soka/
15
- โ”‚ โ”œโ”€โ”€ agent.rb # Agent base class with DSL and execution logic
16
- โ”‚ โ”œโ”€โ”€ agent_tool.rb # Tool base class with parameter validation
17
- โ”‚ โ”œโ”€โ”€ agent_tools/
18
- โ”‚ โ”‚ โ””โ”€โ”€ params_validator.rb # Parameter validation module
19
- โ”‚ โ”œโ”€โ”€ agents/ # Agent feature modules
20
- โ”‚ โ”‚ โ”œโ”€โ”€ dsl_methods.rb # DSL method definitions
21
- โ”‚ โ”‚ โ”œโ”€โ”€ hook_manager.rb # Lifecycle hook management
22
- โ”‚ โ”‚ โ”œโ”€โ”€ llm_builder.rb # LLM instance construction
23
- โ”‚ โ”‚ โ”œโ”€โ”€ retry_handler.rb # Retry mechanism
24
- โ”‚ โ”‚ โ””โ”€โ”€ tool_builder.rb # Tool construction and management
25
- โ”‚ โ”œโ”€โ”€ configuration.rb # Global configuration system
26
- โ”‚ โ”œโ”€โ”€ llm.rb # LLM unified interface layer
27
- โ”‚ โ”œโ”€โ”€ llms/ # LLM provider implementations
28
- โ”‚ โ”‚ โ”œโ”€โ”€ base.rb # LLM base class
29
- โ”‚ โ”‚ โ”œโ”€โ”€ concerns/ # Shared functionality modules
30
- โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ response_parser.rb # Response parsing
31
- โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ streaming_handler.rb # Stream processing
32
- โ”‚ โ”‚ โ”œโ”€โ”€ gemini.rb # Google Gemini implementation
33
- โ”‚ โ”‚ โ”œโ”€โ”€ openai.rb # OpenAI implementation
34
- โ”‚ โ”‚ โ””โ”€โ”€ anthropic.rb # Anthropic implementation
35
- โ”‚ โ”œโ”€โ”€ engines/ # Reasoning engines
36
- โ”‚ โ”‚ โ”œโ”€โ”€ base.rb # Engine base class
37
- โ”‚ โ”‚ โ”œโ”€โ”€ concerns/ # Engine shared modules
38
- โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ prompt_template.rb # Prompt templates
39
- โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ response_processor.rb # Response processing
40
- โ”‚ โ”‚ โ”œโ”€โ”€ react.rb # ReAct reasoning engine
41
- โ”‚ โ”‚ โ””โ”€โ”€ reasoning_context.rb # Reasoning context management
42
- โ”‚ โ”œโ”€โ”€ memory.rb # Conversation memory management
43
- โ”‚ โ”œโ”€โ”€ thoughts_memory.rb # Thought process memory
44
- โ”‚ โ”œโ”€โ”€ result.rb # Result object encapsulation
45
- โ”‚ โ”œโ”€โ”€ test_helpers.rb # RSpec test helpers
46
- โ”‚ โ””โ”€โ”€ version.rb # Version definition
47
- โ”œโ”€โ”€ examples/
48
- โ”‚ โ”œโ”€โ”€ 1_basic.rb # Basic usage example
49
- โ”‚ โ”œโ”€โ”€ 2_event_handling.rb # Event handling example
50
- โ”‚ โ”œโ”€โ”€ 3_memory.rb # Memory usage example
51
- โ”‚ โ”œโ”€โ”€ 4_hooks.rb # Lifecycle hooks example
52
- โ”‚ โ”œโ”€โ”€ 5_error_handling.rb # Error handling example
53
- โ”‚ โ”œโ”€โ”€ 6_retry.rb # Retry mechanism example
54
- โ”‚ โ”œโ”€โ”€ 7_tool_conditional.rb # Conditional tools example
55
- โ”‚ โ””โ”€โ”€ 8_multi_provider.rb # Multi-provider example
56
- โ”œโ”€โ”€ spec/ # RSpec tests
57
- โ””โ”€โ”€ test_soka.rb # Quick test script
37
+ โ”œโ”€โ”€ lib/soka/
38
+ โ”‚ โ”œโ”€โ”€ agent.rb # Core Agent class with DSL
39
+ โ”‚ โ”œโ”€โ”€ agent_tool.rb # Base class for tools
40
+ โ”‚ โ”œโ”€โ”€ agents/ # Agent components (modular design)
41
+ โ”‚ โ”‚ โ”œโ”€โ”€ dsl_methods.rb # DSL for agent configuration
42
+ โ”‚ โ”‚ โ”œโ”€โ”€ hook_manager.rb # Lifecycle hooks
43
+ โ”‚ โ”‚ โ”œโ”€โ”€ llm_builder.rb # LLM instance creation
44
+ โ”‚ โ”‚ โ”œโ”€โ”€ retry_handler.rb # Retry logic
45
+ โ”‚ โ”‚ โ””โ”€โ”€ tool_builder.rb # Tool management
46
+ โ”‚ โ”œโ”€โ”€ engines/ # Reasoning engines
47
+ โ”‚ โ”‚ โ”œโ”€โ”€ react.rb # ReAct implementation
48
+ โ”‚ โ”‚ โ””โ”€โ”€ concerns/ # Shared engine modules
49
+ โ”‚ โ”œโ”€โ”€ llms/ # AI provider integrations
50
+ โ”‚ โ”‚ โ”œโ”€โ”€ gemini.rb # Google Gemini
51
+ โ”‚ โ”‚ โ”œโ”€โ”€ openai.rb # OpenAI GPT
52
+ โ”‚ โ”‚ โ””โ”€โ”€ anthropic.rb # Anthropic Claude
53
+ โ”‚ โ””โ”€โ”€ memory.rb # Conversation memory
54
+ โ”œโ”€โ”€ examples/ # Working examples (1-10)
55
+ โ””โ”€โ”€ spec/ # RSpec tests
56
+ ```
57
+
58
+ ## ๐Ÿ”ง Core Components
59
+
60
+ ### Agent System
61
+ The heart of Soka - defines agents with a simple DSL:
62
+
63
+ ```ruby
64
+ class MyAgent < Soka::Agent
65
+ provider :gemini # Choose AI provider
66
+ model 'gemini-2.5-flash-lite' # Specify model
67
+ max_iterations 10 # Limit reasoning cycles
68
+ timeout 30 # Request timeout
69
+
70
+ # Define tools
71
+ tool :my_tool, 'Description' do
72
+ def call(param:)
73
+ # Tool implementation
74
+ end
75
+ end
76
+
77
+ # Lifecycle hooks
78
+ before_action { |task| log("Starting: #{task}") }
79
+ after_action { |result| log("Completed: #{result}") }
80
+ on_error { |error| handle_error(error) }
81
+ end
82
+ ```
83
+
84
+ ### Tool System
85
+ Create reusable tools with parameter validation:
86
+
87
+ ```ruby
88
+ class WeatherTool < Soka::AgentTool
89
+ desc 'Get weather information'
90
+
91
+ params do
92
+ requires :location, String, desc: 'City name'
93
+ optional :units, String, inclusion: %w[celsius fahrenheit]
94
+ end
95
+
96
+ def call(location:, units: 'celsius')
97
+ # Fetch weather data
98
+ "Weather in #{location}: 22ยฐC, Sunny"
99
+ end
100
+ end
101
+ ```
102
+
103
+ ### ReAct Engine
104
+ Implements the reasoning pattern with structured tags:
105
+
106
+ 1. **Thought**: Agent thinks about the task
107
+ 2. **Action**: Decides which tool to use
108
+ 3. **Observation**: Receives tool results
109
+ 4. **Final Answer**: Provides the solution
110
+
111
+ The engine automatically:
112
+ - Manages iteration loops
113
+ - Calculates confidence scores
114
+ - Handles tool execution
115
+ - Tracks reasoning context
116
+
117
+ ### Memory System
118
+ Two types of memory for different purposes:
119
+
120
+ - **Conversation Memory**: Tracks dialogue history
121
+ - **Thoughts Memory**: Records complete reasoning processes
122
+
123
+ ```ruby
124
+ # Initialize with existing conversation
125
+ memory = Soka::Memory.new
126
+ memory.add(role: 'user', content: 'Previous question')
127
+ memory.add(role: 'assistant', content: 'Previous answer')
128
+
129
+ agent = MyAgent.new(memory: memory)
130
+ ```
131
+
132
+ ## ๐ŸŽจ Advanced Features
133
+
134
+ ### Custom Instructions
135
+ Change your agent's personality and response style:
136
+
137
+ ```ruby
138
+ class FriendlyAgent < Soka::Agent
139
+ provider :gemini
140
+
141
+ # Define personality at class level
142
+ instructions <<~PROMPT
143
+ You are a friendly, helpful assistant.
144
+ Use casual language and be encouraging.
145
+ Add emojis when appropriate.
146
+ PROMPT
147
+ end
148
+
149
+ # Or override at runtime
150
+ agent = FriendlyAgent.new(
151
+ instructions: 'Be more formal and professional.'
152
+ )
153
+ ```
154
+
155
+ ### Multilingual Thinking (Think In)
156
+ Optimize reasoning for specific languages:
157
+
158
+ ```ruby
159
+ class GlobalAgent < Soka::Agent
160
+ provider :gemini
161
+
162
+ # Set default thinking language
163
+ think_in 'zh-TW' # Think in Traditional Chinese
164
+ end
165
+
166
+ # Or set dynamically
167
+ agent = GlobalAgent.new(think_in: 'ja-JP')
168
+ result = agent.run("Help me with this task")
169
+ ```
170
+
171
+ **Key Points:**
172
+ - Thinking language affects internal reasoning only
173
+ - Responses adapt to user's input language
174
+ - Default is English (`'en'`)
175
+ - No automatic language detection (explicit setting required)
176
+
177
+ ### Conditional Tools
178
+ Load tools based on conditions:
179
+
180
+ ```ruby
181
+ class SmartAgent < Soka::Agent
182
+ # Only in development
183
+ tool DebugTool, if: -> { ENV['RAILS_ENV'] == 'development' }
184
+
185
+ # Based on user permissions
186
+ tool AdminTool, if: -> { current_user.admin? }
187
+
188
+ # Feature flags
189
+ tool BetaFeature, if: -> { feature_enabled?(:beta) }
190
+ end
58
191
  ```
59
192
 
60
- ## Core Component Descriptions
61
-
62
- ### 1. Agent System (`agent.rb`)
63
- - Provides DSL for defining AI settings, tool registration, and retry mechanisms
64
- - Supports conditional tool loading (`if:` option)
65
- - Built-in lifecycle hooks (before_action, after_action, on_error)
66
- - Uses `times` loop instead of `loop` for iteration control
67
- - Modular design: functionality separated into concern modules
68
- - `DSLMethods`: DSL method definitions
69
- - `HookManager`: Lifecycle hook management
70
- - `LLMBuilder`: LLM instance construction
71
- - `RetryHandler`: Retry handling
72
- - `ToolBuilder`: Tool construction and management
73
-
74
- ### 2. Tool System (`agent_tool.rb`)
75
- - Grape API-like parameter definition system
76
- - Built-in parameter validation (presence, length, inclusion, format)
77
- - Supports required and optional parameters
78
- - Auto-generates tool description schemas
79
-
80
- ### 3. ReAct Engine (`engines/react.rb`)
81
- - Implements tagged ReAct flow: `<Thought>`, `<Action>`, `<Observation>`, `<Final_Answer>`
82
- - Uses Struct instead of OpenStruct (Rubocop compliant)
83
- - Automatically manages conversation context and tool execution
84
- - Calculates confidence scores (based on iteration count)
85
- - Uses `ReasoningContext` to manage reasoning state
86
- - Shared modules:
87
- - `PromptTemplate`: Prompt template management
88
- - `ResponseProcessor`: Response processing logic
89
-
90
- ### 4. LLM Integration
91
- - **LLM Unified Interface Layer (`llm.rb`)**
92
- - Provides unified API interface
93
- - Supports streaming and non-streaming modes
94
- - Auto-routes to corresponding provider implementation
95
- - **LLM Provider Implementations (`llms/`)**
96
- - Gemini: Uses Google Generative AI API, defaults to `gemini-2.5-flash-lite`
97
- - OpenAI: Supports GPT-4 series, includes streaming capabilities
98
- - Anthropic: Supports Claude 3 series, handles system prompts
99
- - Shared modules:
100
- - `ResponseParser`: Unified response parsing
101
- - `StreamingHandler`: Stream response handling
102
- - Built-in error handling and retry mechanisms
103
-
104
- ### 5. Memory System
105
- - `Memory`: Manages conversation history
106
- - `ThoughtsMemory`: Records complete ReAct thought processes
107
- - Supports initial memory loading
108
-
109
- ## Design Decisions
110
-
111
- ### 1. Using Zeitwerk Autoloading
112
- - Simplifies require management
113
- - Supports hot reloading (development environment)
114
- - Automatically handles namespaces
115
-
116
- ### 2. Dry-rb Ecosystem Integration
117
- - `dry-validation`: Powerful parameter validation
118
- - `dry-struct`: Type-safe data structures
119
- - `dry-types`: Type definitions and coercion
120
-
121
- ### 3. Configuration System Design
122
- - Supports global configuration and instance-level overrides
123
- - Block-style DSL provides intuitive configuration
124
- - Fallback mechanism ensures service availability
125
- - Configuration includes AI providers and performance settings
126
-
127
- ### 4. Error Handling Strategy
128
- - Layered error class inheritance
129
- - Tool execution errors don't interrupt entire flow
130
- - Configurable retry mechanism (exponential backoff)
131
-
132
- ## Testing Strategy
133
-
134
- ### Unit Tests
135
- - Using RSpec 3
136
- - Provides `TestHelpers` module for mocking AI responses
137
- - Supports tool mocking and error simulation
138
-
139
- ### Integration Tests
140
- - `test_soka.rb`: Quick test without real API keys
141
- - `examples/1_basic.rb`: Actual API integration test
142
-
143
- ## Development Guide
144
-
145
- ### Adding New AI Provider
146
- 1. Create new file in `lib/soka/llms/`
193
+ ## ๐Ÿ›  Development Guide
194
+
195
+ ### Creating a New AI Provider
196
+
197
+ 1. Create file in `lib/soka/llms/your_provider.rb`
147
198
  2. Inherit from `Soka::LLMs::Base`
148
199
  3. Implement required methods:
149
- - `default_model`
150
- - `base_url`
151
- - `chat(messages, **params)`
152
- - `parse_response(response)`
153
- 4. Add new provider to `LLM#create_provider` method
154
-
155
- ### Adding New Tools
156
- 1. Inherit from `Soka::AgentTool`
157
- 2. Use `desc` to define description
158
- 3. Use `params` block to define parameters
159
- 4. Implement `call` method
160
-
161
- ### Custom Engines
162
- 1. Inherit from `Soka::Engines::Base`
163
- 2. Implement `reason(task, &block)` method
164
- 3. Use `emit_event` to send events
165
- 4. Return result object inheriting from Struct
166
- 5. Can use concerns modules to share functionality
167
-
168
- ## Rubocop Compatibility
169
- - Complies with Ruby 3.0+ standards
170
- - Major issues fixed:
171
- - Using `Struct` instead of `OpenStruct`
172
- - Using `format` instead of `String#%`
173
- - Using `times` instead of `loop`
174
- - Removed unused MODELS constants
175
-
176
- ## Performance Considerations
177
- - Maximum iteration limit (default 10)
178
- - Request timeout settings (default 30 seconds)
179
- - Memory usage optimization (lazy loading)
180
-
181
- ## Security
182
- - API keys managed through environment variables
183
- - Input parameter validation
184
- - Error messages don't leak sensitive information
185
- - Supports `.env` files (not version controlled)
186
- - Unified error handling hierarchy
187
-
188
- ## Future Extensions
189
- - [ ] Support more LLM providers (Cohere, Hugging Face)
190
- - [ ] Implement caching mechanism
191
- - [ ] Support vector database integration
192
- - [ ] Add more built-in tools
193
- - [ ] WebSocket support for real-time conversations
194
- - [ ] Support functional tools (use methods directly as tools)
195
-
196
- ## Development Standards
197
-
198
- ### Code Quality Checks
200
+
201
+ ```ruby
202
+ module Soka
203
+ module LLMs
204
+ class YourProvider < Base
205
+ def default_model
206
+ 'your-default-model'
207
+ end
208
+
209
+ def base_url
210
+ 'https://api.yourprovider.com'
211
+ end
212
+
213
+ def chat(messages, **params)
214
+ # Make API request
215
+ # Return response
216
+ end
217
+
218
+ def parse_response(response)
219
+ # Parse API response
220
+ # Return standardized format
221
+ end
222
+ end
223
+ end
224
+ end
225
+ ```
226
+
227
+ ### Creating Custom Engines
228
+
229
+ ```ruby
230
+ class MyEngine < Soka::Engines::Base
231
+ def reason(task, &block)
232
+ # Implement your reasoning logic
233
+ emit_event(:thought, "Thinking about: #{task}")
234
+
235
+ # Process and return result
236
+ MyResult.new(
237
+ input: task,
238
+ output: "Processed result",
239
+ status: :success
240
+ )
241
+ end
242
+ end
243
+ ```
244
+
245
+ ## โš™๏ธ Configuration
246
+
247
+ ### Global Configuration
248
+
249
+ ```ruby
250
+ Soka.setup do |config|
251
+ config.ai do |ai|
252
+ ai.provider = :gemini
253
+ ai.model = 'gemini-2.5-flash-lite'
254
+ ai.api_key = ENV['GEMINI_API_KEY']
255
+ end
256
+
257
+ config.performance do |perf|
258
+ perf.max_iterations = 10
259
+ perf.timeout = 30
260
+ end
261
+ end
262
+ ```
263
+
264
+ ### Environment Variables
265
+
266
+ ```bash
267
+ # .env file
268
+ GEMINI_API_KEY=your_api_key
269
+ OPENAI_API_KEY=your_api_key
270
+ ANTHROPIC_API_KEY=your_api_key
271
+ ```
272
+
273
+ ## ๐Ÿ“Š Performance & Security
274
+
275
+ ### Performance Tips
276
+ - Set appropriate `max_iterations` to prevent infinite loops
277
+ - Use `timeout` to handle slow API responses
278
+ - Implement caching for frequently used tools
279
+ - Consider memory limits for long conversations
280
+
281
+ ### Security Best Practices
282
+ - Never commit API keys to version control
283
+ - Use environment variables for sensitive data
284
+ - Validate all tool inputs
285
+ - Sanitize tool outputs before returning
286
+ - Implement rate limiting for production use
287
+
288
+ ## ๐Ÿงช Testing
289
+
290
+ ### Unit Testing
291
+
292
+ ```ruby
293
+ RSpec.describe MyAgent do
294
+ let(:agent) { described_class.new }
295
+
296
+ it 'processes tasks correctly' do
297
+ result = agent.run('Test task')
298
+ expect(result).to be_successful
299
+ expect(result.final_answer).to include('expected')
300
+ end
301
+ end
302
+ ```
303
+
304
+ ### Mocking AI Responses
305
+
306
+ ```ruby
307
+ allow(agent).to receive(:llm).and_return(mock_llm)
308
+ allow(mock_llm).to receive(:chat).and_return(
309
+ double(content: '<Thought>Test</Thought><Final_Answer>Done</Final_Answer>')
310
+ )
311
+ ```
312
+
313
+ ## ๐Ÿ“š Examples
314
+
315
+ The `examples/` directory contains 10 comprehensive examples:
316
+
317
+ 1. **Basic Usage** - Simple agent setup and execution
318
+ 2. **Event Handling** - Responding to agent events
319
+ 3. **Memory Management** - Using conversation memory
320
+ 4. **Lifecycle Hooks** - before/after/error handling
321
+ 5. **Error Handling** - Graceful error management
322
+ 6. **Retry Logic** - Automatic retry configuration
323
+ 7. **Conditional Tools** - Dynamic tool loading
324
+ 8. **Multi-Provider** - Switching between AI providers
325
+ 9. **Custom Instructions** - Personality customization
326
+ 10. **Multilingual Thinking** - Language-specific reasoning
327
+
328
+ ## ๐Ÿ”„ Future Roadmap
329
+
330
+ - [ ] Additional LLM providers (Cohere, Hugging Face)
331
+ - [ ] Built-in caching mechanism
332
+ - [ ] Vector database integration for RAG
333
+ - [ ] More built-in tools (web search, file operations)
334
+ - [ ] WebSocket support for real-time streaming
335
+ - [ ] Direct method-as-tool support
336
+
337
+ ## ๐Ÿ“– Development Standards
338
+
339
+ ### Code Quality
340
+ - Run `bundle exec rubocop` before committing
341
+ - Ensure all tests pass with `bundle exec rspec`
342
+ - Follow Ruby style guide and conventions
343
+ - Keep methods small and focused
344
+ - Write clear, self-documenting code
345
+
346
+ ### Code Quality Checks (Important for AI Assistants)
199
347
  - **When adjusting code, the final step is to run Rubocop to check if the code complies with rules**
200
348
  - **When Rubocop has any issues, fix them until all rules are satisfied**
201
349
  - **When adjusting code, the final step is to perform a code review to avoid redundant design and ensure code conciseness**
@@ -210,4 +358,15 @@ soka/
210
358
  - Include method purpose descriptions
211
359
  - Explain parameter types and purposes
212
360
  - Explain return value types and meanings
213
- - For complex logic, add implementation detail explanations
361
+ - For complex logic, add implementation detail explanations
362
+ - Include usage examples in comments
363
+ - Document all public APIs
364
+ - Keep README and CLAUDE.md updated
365
+
366
+ ## ๐Ÿค Contributing
367
+
368
+ [Contributing Guidelines]
369
+
370
+ ---
371
+
372
+ *Built with โค๏ธ using Ruby and AI*