diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e60aba..86f6d75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixture-backed `evals/skills/triage-bug/basic`: buggy `Discount.apply` (integer division), passing happy-path tests, and a condensed `skills/triage-bug/SKILL.md`. - Fixture-backed `evals/skills/refactor-process/basic`: duplicated `OrderProcessor` methods, passing characterization tests, and a condensed `skills/refactor-process/SKILL.md`. - xAI (Grok) provider: OpenAI-compatible client at `https://api.x.ai/v1/chat/completions`, default model `grok-4`, `skill-bench init --xai`, env `SKILL_BENCH_XAI_API_KEY` or `XAI_API_KEY`. +- Amazon Bedrock provider: Runtime OpenAI-compatible Chat Completions with a Bedrock API key (`AWS_BEARER_TOKEN_BEDROCK` or `SKILL_BENCH_BEDROCK_API_KEY`), default region `us-east-1`, default model `amazon.nova-lite-v1:0`. IAM SigV4 is not included. ### Documentation - Align user docs with shipped 1.3.1: OpenRouter and mock in the provider list, Azure env var `SKILL_BENCH_AZURE_OPENAI_API_KEY`, Mistral key via `skill-bench.json` (no env mapping). diff --git a/README.md b/README.md index fc4b698..397286f 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ See the [Ecosystem Overview](https://github.com/igmarin/agent-mcp-runtime/blob/m - **Isolated Git Sandboxes**: Every run operates in a temporary repo. Clean diffs, zero side-effects, 100% reproducibility. - **Blind Judging with Dimensions**: LLM judge scores baseline and context independently across 5 canonical dimensions (Correctness, Skill Adherence, Code Quality, Test Coverage, Documentation). Eval authors configure weights and thresholds via `criteria.json`. - **Sophisticated ReAct Loop**: Employs a robust `Thought → Tool → Observation` loop to handle complex, multi-step engineering tasks. -- **Multi-Provider Ecosystem**: Native support for **OpenAI**, **Anthropic**, **Google Gemini**, **Azure OpenAI**, **Ollama**, **Groq**, **DeepSeek**, **Mistral**, **OpenCode**, **OpenRouter**, and **xAI**. +- **Multi-Provider Ecosystem**: Native support for **OpenAI**, **Anthropic**, **Google Gemini**, **Azure OpenAI**, **Ollama**, **Groq**, **DeepSeek**, **Mistral**, **OpenCode**, **OpenRouter**, **xAI**, and **Amazon Bedrock**. - **Standardized Intelligence**: Consistent reporting format regardless of the underlying LLM provider. --- @@ -69,6 +69,7 @@ CLI / API → RunnerService → Sandbox + ReAct Agent → LLM Client Layer → P | **OpenCode** | `SKILL_BENCH_OPENCODE_API_KEY`, `SKILL_BENCH_OPENCODE_BASE_URL` | `:opencode` | | **OpenRouter** | `SKILL_BENCH_OPENROUTER_API_KEY` | `:openrouter` | | **xAI** | `SKILL_BENCH_XAI_API_KEY` or `XAI_API_KEY` | `:xai` | +| **Bedrock** | `SKILL_BENCH_BEDROCK_API_KEY` or `AWS_BEARER_TOKEN_BEDROCK` | `:bedrock` | | **Mock** | — (offline, `skill-bench init --mock`) | `:mock` | > **Note:** Environment variables are loaded automatically. You can also configure provider settings in `skill-bench.json` (created by `skill-bench init`). @@ -80,6 +81,8 @@ CLI / API → RunnerService → Sandbox + ReAct Agent → LLM Client Layer → P > **OpenRouter** uses OpenRouter's OpenAI-compatible API (default model `anthropic/claude-3.5-sonnet`). Set `SKILL_BENCH_OPENROUTER_API_KEY` and scaffold with `skill-bench init --openrouter`. > > **xAI** uses xAI's OpenAI-compatible chat completions API (default model `grok-4`). Set `SKILL_BENCH_XAI_API_KEY` or `XAI_API_KEY` and scaffold with `skill-bench init --xai`. +> +> **Amazon Bedrock** uses the Runtime OpenAI-compatible Chat Completions path (`https://bedrock-runtime..amazonaws.com/openai/v1/chat/completions`) with a Bedrock API key. Default region `us-east-1` (`SKILL_BENCH_BEDROCK_REGION` or `AWS_REGION`), default model `amazon.nova-lite-v1:0`. Scaffold with `skill-bench init --bedrock`. IAM SigV4 signing is not in this client. ### Command Allowlist @@ -151,7 +154,7 @@ skill-bench init --openai } ``` -**Available providers:** `--openai`, `--anthropic`, `--gemini`, `--ollama`, `--azure`, `--groq`, `--deepseek`, `--mistral`, `--opencode`, `--openrouter`, `--xai`, plus `--mock` for an offline config with no API key. +**Available providers:** `--openai`, `--anthropic`, `--gemini`, `--ollama`, `--azure`, `--groq`, `--deepseek`, `--mistral`, `--opencode`, `--openrouter`, `--xai`, `--bedrock`, plus `--mock` for an offline config with no API key. **Zero-config offline path:** `skill-bench init --mock` scaffolds a minimal offline config that needs no API key and no network — `{"provider":"mock","max_execution_time":30}`. Use it to try the full flow (and run the bundled examples) before wiring up a real provider. diff --git a/docs/architecture.md b/docs/architecture.md index 2526758..bebe6d6 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -111,7 +111,7 @@ Owns per-dimension arithmetic and the boolean verdict. Does not call the network ### `Clients::BaseClient` and `ProviderRegistry` -Own HTTP to LLM providers (Faraday, retries, response normalization). Registered providers: openai, anthropic, gemini, ollama, azure, groq, deepseek, mistral, opencode, openrouter, xai, plus mock and null. Do not own eval files. +Own HTTP to LLM providers (Faraday, retries, response normalization). Registered providers: openai, anthropic, gemini, ollama, azure, groq, deepseek, mistral, opencode, openrouter, xai, bedrock, plus mock and null. Do not own eval files. ### `Config` diff --git a/docs/first-eval-guide.md b/docs/first-eval-guide.md index 2711de1..1295fac 100644 --- a/docs/first-eval-guide.md +++ b/docs/first-eval-guide.md @@ -42,7 +42,7 @@ skill-bench init --openai This creates `skill-bench.json` with the OpenAI provider config. Use `--force` to overwrite. -**Available providers:** `--openai`, `--anthropic`, `--gemini`, `--ollama`, `--azure`, `--groq`, `--deepseek`, `--mistral`, `--opencode`, `--openrouter`, `--xai`, plus `--mock` for an offline config with no API key. +**Available providers:** `--openai`, `--anthropic`, `--gemini`, `--ollama`, `--azure`, `--groq`, `--deepseek`, `--mistral`, `--opencode`, `--openrouter`, `--xai`, `--bedrock`, plus `--mock` for an offline config with no API key. > **What is `skill-bench.json`?** This is your config file. It stores your API key, chosen LLM model, timeout, and allowed shell commands. Think of it as `.env` but structured as JSON. You edit it; SkillBench reads it. diff --git a/lib/skill_bench/clients/README.md b/lib/skill_bench/clients/README.md index d0554f8..4c64ff9 100644 --- a/lib/skill_bench/clients/README.md +++ b/lib/skill_bench/clients/README.md @@ -29,6 +29,7 @@ graph TD OpenCode[OpenCode] OpenRouter[OpenRouter] Xai[Xai] + Bedrock[Bedrock] Mock[Mock] %% Connections @@ -47,6 +48,7 @@ graph TD Base -.-> OpenCode Base -.-> OpenRouter Base -.-> Xai + Base -.-> Bedrock Base -.-> Mock end @@ -80,6 +82,7 @@ graph TD | **DeepSeek** | `:deepseek` | `DEEPSEEK_*` | Cost-effective alternative | | **OpenCode** | `:opencode` | `OPENCODE_*` | **Custom endpoint required** (self-hosted proxy / LiteLLM / vLLM) | | **xAI** | `:xai` | `SKILL_BENCH_XAI_*` / `XAI_*` | Grok via `https://api.x.ai` | +| **Bedrock** | `:bedrock` | `SKILL_BENCH_BEDROCK_*` / `AWS_BEARER_TOKEN_BEDROCK` | Runtime OpenAI-compatible Chat Completions | | **Null Client** | `:null` | N/A | Mock / Fallback testing | --- diff --git a/lib/skill_bench/clients/all.rb b/lib/skill_bench/clients/all.rb index 9938412..22aa9c1 100644 --- a/lib/skill_bench/clients/all.rb +++ b/lib/skill_bench/clients/all.rb @@ -21,4 +21,5 @@ require_relative 'providers/mistral' require_relative 'providers/openrouter' require_relative 'providers/xai' +require_relative 'providers/bedrock' require_relative 'providers/mock' diff --git a/lib/skill_bench/clients/provider_schemas.rb b/lib/skill_bench/clients/provider_schemas.rb index 0333ef1..c2ff3ae 100644 --- a/lib/skill_bench/clients/provider_schemas.rb +++ b/lib/skill_bench/clients/provider_schemas.rb @@ -55,6 +55,11 @@ class ProviderSchemas xai: { api_key: nil, model: 'grok-4' + }.freeze, + bedrock: { + api_key: nil, + model: 'amazon.nova-lite-v1:0', + location: 'us-east-1' }.freeze }.freeze diff --git a/lib/skill_bench/clients/providers/bedrock.rb b/lib/skill_bench/clients/providers/bedrock.rb new file mode 100644 index 0000000..a5404ea --- /dev/null +++ b/lib/skill_bench/clients/providers/bedrock.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +require_relative '../base_client' +require_relative '../provider_registry' + +module SkillBench + module Clients + module Providers + # Amazon Bedrock LLM client. + # Uses Bedrock Runtime's OpenAI-compatible Chat Completions path with a + # Bedrock API key (bearer). IAM SigV4 signing is a follow-up. + class Bedrock < BaseClient + SkillBench::Clients::ProviderRegistry.register(:bedrock, self) + + DEFAULT_REGION = 'us-east-1' + + # Returns the provider identifier. + # + # @return [Symbol] + def provider_name + :bedrock + end + + protected + + # Returns the Bedrock Runtime host for the configured region. + # + # @return [String] + def base_url + @base_url_config || "https://bedrock-runtime.#{region}.amazonaws.com" + end + + # Returns the OpenAI-compatible chat completions path. + # + # @return [String] + def request_path + @request_path_config || '/openai/v1/chat/completions' + end + + private + + def region + loc = @location.to_s.strip + loc.empty? ? DEFAULT_REGION : loc + end + end + end + end +end diff --git a/lib/skill_bench/config/defaults.rb b/lib/skill_bench/config/defaults.rb index 56d1099..dc1ff11 100644 --- a/lib/skill_bench/config/defaults.rb +++ b/lib/skill_bench/config/defaults.rb @@ -37,7 +37,8 @@ def self.config deepseek: { api_key: nil, model: 'deepseek-chat' }, opencode: { api_key: nil, model: 'opencode-model', base_url: nil }, openrouter: { api_key: nil, model: 'anthropic/claude-3.5-sonnet' }, - xai: { api_key: nil, model: 'grok-4' } + xai: { api_key: nil, model: 'grok-4' }, + bedrock: { api_key: nil, model: 'amazon.nova-lite-v1:0', location: 'us-east-1' } } } end diff --git a/lib/skill_bench/config/env_overrides.rb b/lib/skill_bench/config/env_overrides.rb index 7518466..eb73e8e 100644 --- a/lib/skill_bench/config/env_overrides.rb +++ b/lib/skill_bench/config/env_overrides.rb @@ -53,7 +53,12 @@ class EnvOverrides 'SKILL_BENCH_XAI_API_KEY' => %i[xai api_key], 'XAI_API_KEY' => %i[xai api_key], 'SKILL_BENCH_XAI_MODEL' => %i[xai model], - 'XAI_MODEL' => %i[xai model] + 'XAI_MODEL' => %i[xai model], + 'SKILL_BENCH_BEDROCK_API_KEY' => %i[bedrock api_key], + 'AWS_BEARER_TOKEN_BEDROCK' => %i[bedrock api_key], + 'SKILL_BENCH_BEDROCK_MODEL' => %i[bedrock model], + 'SKILL_BENCH_BEDROCK_REGION' => %i[bedrock location], + 'AWS_REGION' => %i[bedrock location] }.freeze # Returns provider overrides from the given environment. diff --git a/test/evaluator/clients/providers/bedrock_test.rb b/test/evaluator/clients/providers/bedrock_test.rb new file mode 100644 index 0000000..b498250 --- /dev/null +++ b/test/evaluator/clients/providers/bedrock_test.rb @@ -0,0 +1,112 @@ +# frozen_string_literal: true + +require 'test_helper' + +module SkillBench + module Clients + module Providers + class BedrockTest < Minitest::Test + def setup + Config.reset + Config.current_llm_provider = :bedrock + end + + def test_call_returns_message_content_on_success + Config.setup do |config| + config.set_provider_api_key(:bedrock, 'test_bedrock_key') + config.set_provider_location(:bedrock, 'us-west-2') + end + + stub_request(:post, 'https://bedrock-runtime.us-west-2.amazonaws.com/openai/v1/chat/completions') + .to_return( + status: 200, + body: { choices: [{ message: { content: 'Hello from Bedrock', role: 'assistant' } }] }.to_json, + headers: { 'Content-Type' => 'application/json' } + ) + + old_stderr = $stderr + $stderr = StringIO.new + begin + result = Bedrock.call( + api_key: 'test_bedrock_key', + model: 'amazon.nova-lite-v1:0', + location: 'us-west-2', + system_prompt: 'System', + messages: [{ role: 'user', content: 'Hi' }] + ) + ensure + $stderr = old_stderr + end + + assert result[:success] + assert_equal 'Hello from Bedrock', result[:response][:message]['content'] + end + + def test_call_sends_bearer_auth_to_openai_compatible_path + Config.setup do |config| + config.set_provider_api_key(:bedrock, 'test_bedrock_key') + end + + stub = stub_request(:post, 'https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/chat/completions') + .with( + headers: { 'Authorization' => 'Bearer test_bedrock_key' }, + body: hash_including('model' => 'amazon.nova-lite-v1:0') + ) + .to_return( + status: 200, + body: { choices: [{ message: { content: 'ok', role: 'assistant' } }] }.to_json, + headers: { 'Content-Type' => 'application/json' } + ) + + old_stderr = $stderr + $stderr = StringIO.new + begin + Bedrock.call( + api_key: 'test_bedrock_key', + model: 'amazon.nova-lite-v1:0', + system_prompt: 'System', + messages: [{ role: 'user', content: 'Hi' }] + ) + ensure + $stderr = old_stderr + end + + assert_requested stub + end + + def test_call_returns_error_on_missing_api_key + Config.setup do |config| + config.set_provider_api_key(:bedrock, nil) + end + + result = Bedrock.call(api_key: nil, system_prompt: 'System', messages: []) + + refute result[:success] + assert_equal 'API Key not set for Bedrock', result[:response][:error][:message] + end + + def test_provider_name + client = Bedrock.new(system_prompt: '', messages: []) + + assert_equal :bedrock, client.provider_name + end + + def test_default_region_is_us_east1 + client = Bedrock.new(system_prompt: '', messages: []) + + assert_equal 'https://bedrock-runtime.us-east-1.amazonaws.com', client.send(:base_url) + end + + def test_request_path + client = Bedrock.new(system_prompt: '', messages: []) + + assert_equal '/openai/v1/chat/completions', client.send(:request_path) + end + + def test_schema_default_model + assert_equal 'amazon.nova-lite-v1:0', ProviderSchemas.for(:bedrock)[:model] + end + end + end + end +end diff --git a/test/evaluator/config/env_overrides_test.rb b/test/evaluator/config/env_overrides_test.rb index 4730b68..20f8ef7 100644 --- a/test/evaluator/config/env_overrides_test.rb +++ b/test/evaluator/config/env_overrides_test.rb @@ -36,6 +36,22 @@ def test_omits_absent_env_values assert_equal({}, result[:response][:overrides]) end + def test_maps_bedrock_bearer_token_and_region + result = EnvOverrides.call( + env: { + 'AWS_BEARER_TOKEN_BEDROCK' => 'bedrock-token', + 'SKILL_BENCH_BEDROCK_REGION' => 'eu-west-1', + 'SKILL_BENCH_BEDROCK_MODEL' => 'amazon.nova-lite-v1:0' + } + ) + + assert result[:success] + assert_equal( + { bedrock: { api_key: 'bedrock-token', location: 'eu-west-1', model: 'amazon.nova-lite-v1:0' } }, + result[:response][:overrides] + ) + end + def test_maps_xai_api_key_from_prefixed_and_native_env result = EnvOverrides.call( env: { diff --git a/test/test_helper.rb b/test/test_helper.rb index 1a60321..a1da2b9 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -21,9 +21,10 @@ # # Strip both SKILL_BENCH__ and legacy _ # for every EnvOverrides-capable setting on every registered provider. -%w[OPENAI ANTHROPIC GEMINI OLLAMA AZURE GROQ DEEPSEEK MISTRAL OPENCODE OPENROUTER XAI] - .product(%w[API_KEY MODEL BASE_URL ENDPOINT LOCATION PROJECT_ID API_VERSION]) +%w[OPENAI ANTHROPIC GEMINI OLLAMA AZURE GROQ DEEPSEEK MISTRAL OPENCODE OPENROUTER XAI BEDROCK] + .product(%w[API_KEY MODEL BASE_URL ENDPOINT LOCATION PROJECT_ID API_VERSION REGION]) .each do |provider, setting| ENV.delete("#{provider}_#{setting}") ENV.delete("SKILL_BENCH_#{provider}_#{setting}") end +%w[AWS_REGION AWS_DEFAULT_REGION AWS_BEARER_TOKEN_BEDROCK].each { |key| ENV.delete(key) }