Skip to content

Commit d818575

Browse files
authored
Major Framework Refactor: ActiveAgent v1.0.0 (#259)
* Add ENV to .gitignore * Rename Provider "Base" to "BaseProvider" * Move Provider Concerns into folder * Improve Provider Deps Loading * Refactor Provider Options * [WIP] Refactor Providers * Refactor Anthropic Options & Provider clients * [WIP] Boil the Ocean - OpenAI Responses API Basic Support * [WIP] Boil the Ocean - OpenAI Chat API Basic Support * [WIP] Boil the Ocean - OpenAI Chat API Streaming Support * [WIP] Boil the Ocean - Refactor OpenAI Specs * [WIP] Boil the Ocean - OpenAI Chat API Web Search Support * [WIP] Boil the Ocean - OpenAI Responses API Streaming Support * [WIP] Boil the Ocean - OpenAI Responses & Chat API Streaming Functions Resolving * [WIP] Boil the Ocean - OpenAI Responses & Chat API > Defer Client & Context Resolving * [WIP] Boil the Ocean - OpenAI Stabilized (Native Format) * [WIP] Boil the Ocean - Add Basic [Native Format] OpenRouter Support * [WIP] Boil the Ocean - Full Core Native Format Support For OpenAI, Ollama, OpenRouter * [WIP] Boil the Ocean - Core Native Format Support For Anthropic * [WIP] Provider Cleanup * [WIP] Improve Streaming API * [WIP] Refactor Rescuable * [WIP] Add OpenAI & Ollama Embedding * [WIP] Improve comments * [WIP] Move Observers to a Concern * [WIP] Add Support for Common Instructions Formats * [WIP] Create Updated Common Response Format * [WIP] Improve Embedding Response parsing * [WIP] Improve Instructions rendering from symbols to match Rails * [WIP] Cleanups * [WIP] Improve Retries and Configuration * [WIP] Add improved logging * [WIP] Cleanups * [WIP] Fix Tests * [WIP] Fix logging & Add Trace IDs * [WIP] Create Improved Messages Common Format - Anthropic * [WIP] Create Improved Messages Common Format - OpenAI * [WIP] Create Improved Messages Common Format - OpenRouter & Ollama * [WIP] Setup Action-level template rendering * [WIP] Add tests for Structured Ouputs * [WIP] Cleanups * [WIP] Improve prompt_context api with .prompt(...) * [WIP] Docs * [WIP] Create Mock Provider * [WIP] Get Docs to Build Again * [WIP] Docs - Overview * [WIP] Docs - Framework * [WIP] Add/Fix md template rendering * [WIP] Docs - Agent Instructions * [WIP] Dep injection fixes * [WIP] Fix Anthropic Error Handling * [WIP] Add response_type json_object emulated support for Anthropic * [WIP] Fix agent template loading paths * [WIP] OpenAI Responses API json_object support * [WIP] Fix Direct Parameterized Calls * [WIP] Create Streaming Docs * [WIP] Update Generation Docs * [WIP] Improve Callbacks Docs * [WIP] Improve Error Handling Docs * [WIP] Update OpenAI Provider Docs * [WIP] Improve Ollama Support & Docs * [WIP] Improve OpenRouter Support & Docs * [WIP] Finish Provider Docs * [WIP] Fix Instrumentation * [WIP] Update Embedding Docs * [WIP] Prune Docs * [WIP] Update Messages Docs * [WIP] Fix Docs/Tests * [WIP] Improve and Document Structured Output Support * [WIP] Update Tools Docs * [WIP] Update Actions Docs * [WIP] Update Agents Docs * [WIP] Update Framework Docs * [WIP] Improve Rails Docs, Generators, and Schema Loading * Fix tests & Cleanups * Bump Version to 1.0.0 and Update CHANGELOG * Fix CI * Migrate to official OpenAI SDK * Replace custom retries with provider SDK retry mechanisms * Avoid bug in AbstractController::Collector by using .json instead of .schema.json for JSON Schema loading * Improve Callbacks verbage * Fix Message Comparisons * Fix proc parameters resolving leaking into agent context * Fix Instructions rendering bugs * Fix callbacks vs proc resolving execution order * Add missing Callback control methods * Fix OpenAI Responses API Base64 Document Support * Fix inconsistent Model schema generation format * Update Data Extraction Example * Improve Docs Site Indexing & Navigation * Uplevel Provider context methods to class-level * Fix issue with double error handling by removing top-level redundant handler * Refactor Providers api_prompt_execute * Add the ability to render prompt previews * Improve Generation Callbacks & Instructions Template * Improve Preview formatting
1 parent d8fb8f0 commit d818575

1,026 files changed

Lines changed: 188258 additions & 96893 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828
BUNDLE_RETRY: 3
2929
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
3030
CI: true
31+
ANTHROPIC_API_KEY: ANTHROPIC_API_KEY
32+
OPEN_AI_API_KEY: OPEN_AI_API_KEY
33+
OPEN_ROUTER_API_KEY: OPEN_ROUTER_API_KEY
3134
strategy:
3235
fail-fast: false
3336
matrix:

.gitignore

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
.env*
2+
.ruby-version
3+
*.onnx
4+
**/.DS_Store
15
/.bundle/
26
/doc/
37
/log/*.log
8+
/node_modules/
49
/pkg/
5-
/tmp/
610
/test/dummy/db/*.sqlite3
711
/test/dummy/db/*.sqlite3-*
812
/test/dummy/log/*.log
913
/test/dummy/storage/
1014
/test/dummy/tmp/
11-
/node_modules/
12-
**/.DS_Store
13-
test/dummy/config/master.key
14-
docs/.vitepress/dist
15+
/tmp/
1516
docs/.vitepress/cache
17+
docs/.vitepress/dist
1618
docs/parts/examples/*.md
17-
*.onnx
19+
Gemfile.lock
1820
gemfiles/*.lock
19-
Gemfile.lock
21+
test/dummy/config/master.key

CHANGELOG.md

Lines changed: 210 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,214 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.0] - Unreleased
9+
10+
Major refactor with breaking changes. Complete provider rewrite. New modular architecture.
11+
12+
**Requirements:** Ruby 3.1+, Rails 7.0+/8.0+/8.1+
13+
14+
### Breaking Changes
15+
16+
#### 1. Update Provider Gems
17+
18+
```ruby
19+
# Gemfile - Remove unofficial gems
20+
gem "ruby-openai"
21+
gem "ruby-anthropic"
22+
23+
# Add official provider SDKs
24+
gem "openai" # Official OpenAI SDK
25+
gem "anthropic" # Official Anthropic SDK
26+
```
27+
28+
Run `bundle install` after updating.
29+
30+
#### 2. Update Base Class
31+
32+
```ruby
33+
# Before
34+
class MyAgent < ActiveAgent::ActionPrompt::Base
35+
end
36+
37+
# After
38+
class MyAgent < ActiveAgent::Base
39+
end
40+
```
41+
42+
#### 3. Configure Providers
43+
44+
```ruby
45+
# Before - options wrapped in options key
46+
class MyAgent < ActiveAgent::Base
47+
def chat
48+
prompt(message: "Hello", options: { temperature: 0.7 })
49+
end
50+
end
51+
52+
# After - options passed directly (at class or call level)
53+
class MyAgent < ActiveAgent::Base
54+
generate_with :openai, model: "gpt-4o-mini", temperature: 0.7
55+
56+
def chat
57+
prompt("Hello") # Uses class-level config
58+
end
59+
60+
def chat_creative
61+
prompt("Hello", temperature: 1.0) # Override per-call
62+
end
63+
end
64+
```
65+
66+
#### 4. Update Custom Providers (if any)
67+
68+
```ruby
69+
# Before
70+
module ActiveAgent::GenerationProvider
71+
class CustomProvider < Base
72+
end
73+
end
74+
75+
# After
76+
module ActiveAgent::Providers
77+
class CustomProvider < BaseProvider
78+
end
79+
end
80+
```
81+
82+
#### 5. Update Generator Commands
83+
84+
```bash
85+
# Before
86+
rails g active_agent MyAgent action
87+
88+
# After
89+
rails g active_agent:agent MyAgent action
90+
```
91+
92+
#### 6. Remove Framework Retry Config
93+
94+
```ruby
95+
# Remove from config/initializers/activeagent.rb
96+
ActiveAgent.configure do |config|
97+
config.retries = true
98+
config.retries_count = 5
99+
end
100+
101+
# Use provider-specific settings in config/active_agent.yml
102+
openai:
103+
service: "OpenAI"
104+
max_retries: 5
105+
timeout: 600.0
106+
```
107+
108+
Template paths:
109+
- `app/views/agents/{agent}/instructions.md` (no `.erb` extension by default for instructions)
110+
- `app/views/agents/{agent}/{action}.md.erb`
111+
112+
### Added
113+
114+
**Mock Provider for Testing**
115+
```ruby
116+
class MyAgent < ActiveAgent::Base
117+
generate_with :mock
118+
end
119+
120+
response = MyAgent.prompt("Test").generate_now
121+
# Returns predictable responses without API calls
122+
```
123+
124+
**Mixed Provider Support**
125+
```ruby
126+
class MyAgent < ActiveAgent::Base
127+
generate_with :openai, model: "gpt-4o-mini"
128+
embed_with :anthropic, model: "claude-3-5-sonnet-20241022"
129+
end
130+
```
131+
132+
**Prompt Previews**
133+
```ruby
134+
preview = MyAgent.prompt("Hello").prompt_preview
135+
# Shows instructions, messages, tools before execution
136+
```
137+
138+
**Callback Lifecycle**
139+
- `before_generation`, `after_generation`, `around_generation`
140+
- `before_prompt`, `after_prompt`, `around_prompt`
141+
- `before_embed`, `after_embed`, `around_embed`
142+
- `on_stream_open`, `on_stream`, `on_stream_close`
143+
- Rails-style callback control: `prepend_*`, `skip_*`, `append_*`
144+
145+
**Multi-Input Embeddings**
146+
```ruby
147+
response = MyAgent.embed(inputs: ["Text 1", "Text 2"]).embed_now
148+
vectors = response.data.map { |d| d[:embedding] }
149+
```
150+
151+
**Provider Enhancements**
152+
- OpenAI Responses API: `api: :responses` or `api: :chat`
153+
- Anthropic JSON object mode with automatic extraction
154+
- OpenRouter: quantization, provider preferences, web search
155+
- Flexible naming: `:openai` or `:open_ai`, `:openrouter` or `:open_router`
156+
157+
**Rails 8.1 Support**
158+
159+
**Comprehensive Documentation**
160+
- VitePress site at docs.activeagents.ai
161+
- All examples tested and validated
162+
163+
### Changed
164+
165+
**Provider Architecture**
166+
- Unified `BaseProvider` interface across all providers
167+
- Retry logic moved to provider SDKs (automatic exponential backoff)
168+
- Migrated to official SDKs: `openai` gem and `anthropic` gem
169+
- Type-safe options with per-provider definitions
170+
171+
**Configuration**
172+
- Options configurable at class level, instance level, or per-call
173+
- Simplified parameter handling pattern
174+
175+
**Requirements**
176+
- Ruby 3.1+ (previously 3.0+)
177+
178+
**Testing**
179+
- Reorganized by feature and provider integration
180+
- All documentation examples validated
181+
182+
### Fixed
183+
184+
**Providers**
185+
- OpenAI streaming with functions/tools
186+
- Ollama streaming support
187+
- Anthropic tool choice modes (`any` and `tool`)
188+
- OpenRouter model fallback and parameter naming
189+
- Provider gem loading errors
190+
191+
**Framework**
192+
- Streaming lifecycle with function/tool calls
193+
- Multi-tool and multi-turn conversation handling
194+
- Options mutation during generation
195+
- Template rendering without blocks
196+
- Schema generator key symbolization
197+
- Rails 8.0 and 8.1 compatibility
198+
199+
### Removed
200+
201+
**Namespaces**
202+
- `ActiveAgent::ActionPrompt` → use `ActiveAgent::Base`
203+
- `ActiveAgent::GenerationProvider` → use `ActiveAgent::Providers`
204+
205+
**Configuration**
206+
- `ActiveAgent.configuration.retries` → use provider `max_retries`
207+
- `ActiveAgent.configuration.retries_count` → use provider `max_retries`
208+
- `ActiveAgent.configuration.retries_on` → handled by provider SDKs
209+
210+
**Modules**
211+
- `ActiveAgent::QueuedGeneration``Queueing` concern
212+
- `ActiveAgent::Rescuable``Rescue` concern
213+
- `ActiveAgent::Sanitizers` → moved to concerns
214+
- `ActiveAgent::PromptHelper` → moved to concerns
215+
8216
## [0.3.2] - 2025-04-15
9217

10218
### Added
@@ -13,5 +221,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13221
- Enhance streaming to support tool calls during stream. Previously, streaming mode blocked tool call execution.
14222
- Fix layout rendering bug when no block is passed and views now render correctly without requiring a block.
15223

16-
### Removed
17-
- Generation Provider module and Action Prompt READMEs have been removed, but will be updated along with the main README in the next release.
224+
### Removed
225+
- Generation Provider module and Action Prompt READMEs have been removed, but will be updated along with the main README in the next release.

0 commit comments

Comments
 (0)