Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixture-backed `evals/skills/write-yard-docs/basic`: undocumented `PriceCalculator`, passing starting tests, and a condensed `skills/write-yard-docs/SKILL.md`.
- 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`.

### 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).
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**, and **OpenRouter**.
- **Multi-Provider Ecosystem**: Native support for **OpenAI**, **Anthropic**, **Google Gemini**, **Azure OpenAI**, **Ollama**, **Groq**, **DeepSeek**, **Mistral**, **OpenCode**, **OpenRouter**, and **xAI**.
- **Standardized Intelligence**: Consistent reporting format regardless of the underlying LLM provider.

---
Expand Down Expand Up @@ -68,6 +68,7 @@ CLI / API → RunnerService → Sandbox + ReAct Agent → LLM Client Layer → P
| **Mistral** | set `api_key` in `skill-bench.json` (no env mapping) | `:mistral` |
| **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` |
| **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`).
Expand All @@ -77,6 +78,8 @@ CLI / API → RunnerService → Sandbox + ReAct Agent → LLM Client Layer → P
> **Mistral** uses Mistral's OpenAI-compatible chat completions API (default model `mistral-large-latest`). Scaffold with `skill-bench init --mistral` and set `config.api_key` in `skill-bench.json`. There is no `SKILL_BENCH_MISTRAL_API_KEY` env mapping.
>
> **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`.

### Command Allowlist

Expand Down Expand Up @@ -148,7 +151,7 @@ skill-bench init --openai
}
```

**Available providers:** `--openai`, `--anthropic`, `--gemini`, `--ollama`, `--azure`, `--groq`, `--deepseek`, `--mistral`, `--opencode`, `--openrouter`, plus `--mock` for an offline config with no API key.
**Available providers:** `--openai`, `--anthropic`, `--gemini`, `--ollama`, `--azure`, `--groq`, `--deepseek`, `--mistral`, `--opencode`, `--openrouter`, `--xai`, 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.

Expand Down
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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, plus mock and null. Do not own eval files.

### `Config`

Expand Down
2 changes: 1 addition & 1 deletion docs/first-eval-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`, plus `--mock` for an offline config with no API key.
**Available providers:** `--openai`, `--anthropic`, `--gemini`, `--ollama`, `--azure`, `--groq`, `--deepseek`, `--mistral`, `--opencode`, `--openrouter`, `--xai`, 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.

Expand Down
3 changes: 3 additions & 0 deletions lib/skill_bench/clients/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ graph TD
Mistral[Mistral]
OpenCode[OpenCode]
OpenRouter[OpenRouter]
Xai[Xai]
Mock[Mock]

%% Connections
Expand All @@ -45,6 +46,7 @@ graph TD
Base -.-> Mistral
Base -.-> OpenCode
Base -.-> OpenRouter
Base -.-> Xai
Base -.-> Mock
end

Expand Down Expand Up @@ -77,6 +79,7 @@ graph TD
| **Groq** | `:groq` | `GROQ_*` | High-speed inference |
| **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` |
| **Null Client** | `:null` | N/A | Mock / Fallback testing |

---
Expand Down
1 change: 1 addition & 0 deletions lib/skill_bench/clients/all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
require_relative 'providers/deepseek'
require_relative 'providers/mistral'
require_relative 'providers/openrouter'
require_relative 'providers/xai'
require_relative 'providers/mock'
4 changes: 4 additions & 0 deletions lib/skill_bench/clients/provider_schemas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class ProviderSchemas
openrouter: {
api_key: nil,
model: 'anthropic/claude-3.5-sonnet'
}.freeze,
xai: {
api_key: nil,
model: 'grok-4'
}.freeze
}.freeze

Expand Down
43 changes: 43 additions & 0 deletions lib/skill_bench/clients/providers/xai.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# frozen_string_literal: true

require_relative '../base_client'
require_relative '../provider_registry'

module SkillBench
module Clients
module Providers
# xAI (Grok) LLM client.
# Uses xAI's OpenAI-compatible chat completions API with bearer-token auth.
class Xai < BaseClient
SkillBench::Clients::ProviderRegistry.register(:xai, self)

# Returns the provider identifier.
#
# @return [Symbol]
def provider_name
:xai
end

protected

# Returns the base URL for the xAI API.
#
# The version segment lives in {#request_path} so Faraday does not drop
# it (an absolute request path replaces any path component of the
# connection base URL).
#
# @return [String]
def base_url
@base_url_config || 'https://api.x.ai'
end

# Returns the request path for chat completions.
#
# @return [String]
def request_path
@request_path_config || '/v1/chat/completions'
end
end
end
end
end
3 changes: 2 additions & 1 deletion lib/skill_bench/config/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def self.config
groq: { api_key: nil, model: 'llama-3.3-70b-versatile' },
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' }
openrouter: { api_key: nil, model: 'anthropic/claude-3.5-sonnet' },
xai: { api_key: nil, model: 'grok-4' }
}
}
end
Expand Down
6 changes: 5 additions & 1 deletion lib/skill_bench/config/env_overrides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ class EnvOverrides
'SKILL_BENCH_OPENCODE_MODEL' => %i[opencode model],
'OPENCODE_MODEL' => %i[opencode model],
'SKILL_BENCH_OPENROUTER_API_KEY' => %i[openrouter api_key],
'SKILL_BENCH_OPENROUTER_MODEL' => %i[openrouter model]
'SKILL_BENCH_OPENROUTER_MODEL' => %i[openrouter model],
'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]
}.freeze

# Returns provider overrides from the given environment.
Expand Down
114 changes: 114 additions & 0 deletions test/evaluator/clients/providers/xai_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# frozen_string_literal: true

require 'test_helper'

module SkillBench
module Clients
module Providers
class XaiTest < Minitest::Test
def setup
Config.reset
Config.current_llm_provider = :xai
end

def test_call_returns_message_content_on_success
Config.setup do |config|
config.set_provider_api_key(:xai, 'test_xai_key')
end

stub_request(:post, 'https://api.x.ai/v1/chat/completions')
.to_return(
status: 200,
body: { choices: [{ message: { content: 'Hello from Grok', role: 'assistant' } }] }.to_json,
headers: { 'Content-Type' => 'application/json' }
)

old_stderr = $stderr
$stderr = StringIO.new
begin
result = Xai.call(
api_key: 'test_xai_key',
model: 'grok-4',
system_prompt: 'System',
messages: [{ role: 'user', content: 'Hi' }]
)
ensure
$stderr = old_stderr
end

assert result[:success]
assert_equal 'Hello from Grok', result[:response][:message]['content']
end

def test_call_sends_request_to_xai_endpoint_with_bearer_auth
Config.setup do |config|
config.set_provider_api_key(:xai, 'test_xai_key')
end

stub = stub_request(:post, 'https://api.x.ai/v1/chat/completions')
.with(
headers: { 'Authorization' => 'Bearer test_xai_key' },
body: hash_including('model' => 'grok-4')
)
.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
Xai.call(
api_key: 'test_xai_key',
model: 'grok-4',
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(:xai, nil)
end

result = Xai.call(
api_key: nil,
system_prompt: 'System',
messages: []
)

refute result[:success]
assert_equal 'API Key not set for Xai', result[:response][:error][:message]
end

def test_provider_name
client = Xai.new(system_prompt: '', messages: [])

assert_equal :xai, client.provider_name
end

def test_base_url
client = Xai.new(system_prompt: '', messages: [])

assert_equal 'https://api.x.ai', client.send(:base_url)
end

def test_request_path
client = Xai.new(system_prompt: '', messages: [])

assert_equal '/v1/chat/completions', client.send(:request_path)
end

def test_schema_default_model_is_grok4
assert_equal 'grok-4', ProviderSchemas.for(:xai)[:model]
end
end
end
end
end
16 changes: 16 additions & 0 deletions test/evaluator/config/env_overrides_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ def test_omits_absent_env_values
assert result[:success]
assert_equal({}, result[:response][:overrides])
end

def test_maps_xai_api_key_from_prefixed_and_native_env
result = EnvOverrides.call(
env: {
'SKILL_BENCH_XAI_API_KEY' => 'prefixed-key',
'XAI_API_KEY' => 'native-key',
'SKILL_BENCH_XAI_MODEL' => 'grok-4'
}
)

assert result[:success]
assert_equal(
{ xai: { api_key: 'native-key', model: 'grok-4' } },
result[:response][:overrides]
)
end
end
end
end
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
# Strip both SKILL_BENCH_<PROVIDER>_<SETTING> and legacy <PROVIDER>_<SETTING>
# for every EnvOverrides-capable setting on every registered provider.
%w[OPENAI ANTHROPIC GEMINI OLLAMA AZURE GROQ DEEPSEEK MISTRAL OPENCODE OPENROUTER]
%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])
.each do |provider, setting|
ENV.delete("#{provider}_#{setting}")
Expand Down
Loading