-
Notifications
You must be signed in to change notification settings - Fork 4
fix ruby-llm attachment issue #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| --- | ||
| name: fix-integration-bug | ||
| description: Workflow for fixing bugs in Ruby SDK integrations. Covers reproducing the bug, using appraisals, adding test cases, and TDD-based fixes. | ||
| --- | ||
|
|
||
| # Fixing Integration Bugs | ||
|
|
||
| **This skill is for fixing bugs in existing integrations.** Follow this workflow to reproduce, test, and fix integration issues. | ||
|
|
||
| ## 1. Reproduce the Bug | ||
|
|
||
| First, understand and reproduce the issue: | ||
|
|
||
| ```bash | ||
| # Run with console logging to see actual trace output | ||
| BRAINTRUST_ENABLE_TRACE_CONSOLE_LOG=true bundle exec appraisal provider ruby examples/provider.rb | ||
|
|
||
| # Or create a minimal reproduction script | ||
| BRAINTRUST_ENABLE_TRACE_CONSOLE_LOG=true bundle exec appraisal provider ruby -e ' | ||
| require "braintrust" | ||
| # minimal reproduction code | ||
| ' | ||
| ``` | ||
|
|
||
| ## 2. Appraisal Commands | ||
|
|
||
| Test against specific gem versions: | ||
|
|
||
| ```bash | ||
| # Install dependencies for all appraisals | ||
| bundle exec appraisal install | ||
|
|
||
| # Run tests for specific appraisal | ||
| bundle exec appraisal provider rake test | ||
|
|
||
| # Run single test file | ||
| bundle exec appraisal provider rake test TEST=test/braintrust/trace/provider_test.rb | ||
|
|
||
| # Run with specific seed (useful for reproducing flaky test failures from CI) | ||
| bundle exec appraisal provider rake test[12345] | ||
|
|
||
| # Run all appraisals | ||
| bundle exec appraisal rake test | ||
|
|
||
| # Re-record VCR cassettes | ||
| VCR_MODE=all bundle exec appraisal provider rake test | ||
| ``` | ||
|
|
||
| ## 3. Add Failing Test Case | ||
|
|
||
| Write a test that reproduces the bug: | ||
|
|
||
| ```ruby | ||
| def test_bug_description | ||
| # Arrange: Set up the scenario that triggers the bug | ||
|
|
||
| # Act: Call the method | ||
|
|
||
| # Assert: Verify expected behavior (this should FAIL initially) | ||
| end | ||
| ``` | ||
|
|
||
| ## 4. Add Example Case (if applicable) | ||
|
|
||
| Add a case to the internal example that exercises the buggy code path: | ||
|
|
||
| - **Location**: `examples/internal/provider.rb` | ||
| - **Purpose**: Demonstrates the fix works end-to-end | ||
| - Follow existing example patterns (nest under root span, print output) | ||
|
|
||
| ## 5. TDD Fix Cycle | ||
|
|
||
| 1. Run failing test: `bundle exec appraisal provider rake test` | ||
| 2. Implement minimal fix in `lib/braintrust/trace/contrib/provider.rb` | ||
| 3. Run tests again (should pass) | ||
| 4. Lint: `bundle exec rake lint:fix` | ||
| 5. Run all appraisals: `bundle exec appraisal rake test` | ||
|
|
||
| ## 6. Verify with MCP | ||
|
|
||
| Query traces to confirm the fix: | ||
|
|
||
| ```ruby | ||
| mcp__braintrust__btql_query(query: "SELECT input, output, metrics FROM project_logs LIMIT 5") | ||
| ``` | ||
|
|
||
| ## Reference Files | ||
|
|
||
| - Integrations: `lib/braintrust/trace/contrib/{openai,anthropic,ruby_llm}.rb` | ||
| - Tests: `test/braintrust/trace/{openai,anthropic,ruby_llm}_test.rb` | ||
| - Examples: `examples/internal/{openai,anthropic,ruby_llm}.rb` | ||
| - VCR cassettes: `test/fixtures/vcr_cassettes/provider/` | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Braintrust Ruby SDK | ||
|
|
||
| Ruby SDK for Braintrust observability (tracing, evals, logging). | ||
|
|
||
| ## Code Structure | ||
|
|
||
| - `lib/braintrust/` - Main SDK code | ||
| - `trace.rb`, `trace/` - Tracing/spans for LLM calls | ||
| - `eval.rb`, `eval/` - Evaluation framework | ||
| - `api.rb`, `api/` - API client | ||
| - `state.rb` - Global state management | ||
| - `test/` - Tests mirror lib/ structure | ||
| - `examples/` - Usage examples | ||
|
|
||
| ## Commands | ||
|
|
||
| ```bash | ||
| rake # Run lint + all appraisal tests (CI) | ||
| rake test # Run tests | ||
| rake lint # StandardRB linter | ||
| rake lint:fix # Auto-fix lint issues | ||
| rake -T # List all tasks | ||
| ``` | ||
|
|
||
| ## TDD | ||
|
|
||
| Reproduce the issue in a failing test before fixing it. | ||
|
|
||
| ## Testing | ||
|
|
||
| **Prefer real code over mocks.** Use VCR to record/replay HTTP interactions. | ||
|
|
||
| ```bash | ||
| rake test # Run with VCR cassettes | ||
| VCR_MODE=all rake test # Re-record all cassettes | ||
| VCR_MODE=new_episodes rake test # Record new, keep existing | ||
| ``` | ||
|
|
||
| ### Appraisals (Optional Dependencies) | ||
|
|
||
| The SDK integrates with optional gems (openai, anthropic, ruby_llm). Tests run against multiple versions: | ||
|
|
||
| ```bash | ||
| bundle exec appraisal list # Show scenarios | ||
| bundle exec appraisal openai rake test # Test with openai gem | ||
| bundle exec appraisal openai-uninstalled rake test # Test without | ||
| ``` | ||
|
|
||
| ## Linting | ||
|
|
||
| Uses StandardRB. Run `rake lint:fix` before committing. |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.