openevolve-bedrock
Amazon Bedrock as the LLM backend for OpenEvolve, the open-source AlphaEvolve-class evolutionary coding agent — plus a per-call usage ledger so a run reports what it cost, not just what it found.
llm:
provider: bedrock
api_base: aws://us-west-2
models:
- name: us.anthropic.claude-haiku-5-5 # breadth
weight: 0.8
- name: us.anthropic.claude-sonnet-5-5 # depth
weight: 0.2
pip install openevolve-bedrock
oe-bedrock run initial_program.py evaluator.py --config config.yaml --iterations 100
oe-bedrock cost openevolve_output/ --pricing pricing.yaml --threshold 0.99
What it does
OpenEvolve's loop is unchanged: prompt sampler → weighted LLM ensemble →
your evaluate() → MAP-Elites archive with islands. This package replaces the
model calls and adds accounting:
| Two transports | api_base: aws://<region> uses the Converse API through boto3 (SigV4, IAM roles, instance profiles, or a Bedrock API key in AWS_BEARER_TOKEN_BEDROCK). An https:// api_base uses Bedrock's OpenAI-compatible Chat Completions (bedrock-mantle.<region>.api.aws/v1 or bedrock-runtime.<region>.amazonaws.com/openai/v1) with a Bedrock API key, or short-term keys minted from your AWS credentials when none is set. Same config, same ledger; swap the URL to compare endpoints. |
| Any Bedrock model | Any text model Bedrock serves, from any vendor: Claude, Nova, Llama, Mistral, DeepSeek, Qwen, OpenAI, Moonshot, Z.AI, MiniMax, xAI, Gemma, Nemotron… Models disagree on what a request may contain (cache point, temperature, thinking and reasoning fields), so the provider sends the current-generation shape and, when Bedrock rejects a field, drops or swaps it for that model, retries without spending a retry attempt, and remembers for the rest of the process. One warning per model and adaptation is logged. No model table to go stale. |
| Prompt caching | Converse transport adds a cache point after the system message; models that don't take one are detected on the first call. Cache hits require the system message to clear the model's minimum — 512 tokens on current Claude models, up to 4096 on some (Claude Haiku 4.5): put the stable problem description and instructions in prompt.system_message, not the user turn. Some models cache on their own (xAI Grok). OE_BEDROCK_CACHE=off disables the cache point. |
| Throttle-aware retry | ThrottlingException, 429, ServiceUnavailable, ModelNotReady and connection errors are retried with exponential backoff and jitter (OE_BEDROCK_MAX_ATTEMPTS, default 8). Throttles are counted in the ledger so you can see what your island parallelism is costing in wall-clock. |
| Parameter hygiene | seed is never sent (Bedrock rejects it); top_p: null is never sent (openevolve #414); temperature/top_p are dropped for models that reject them (current Claude, GPT-5.5/6.x, Grok, Kimi K3). reasoning_effort maps to Claude adaptive thinking with output_config.effort (falling back to a budget_tokens budget on models without adaptive thinking, e.g. Haiku 4.5; OE_BEDROCK_THINKING_BUDGET=N asks for a budget), and to reasoning_effort or reasoning.effort for other vendors, dropped where neither is accepted. |
| Ledger | One JSON line per call: model, transport, input/output/cache-read/cache-write tokens, latency, attempts, throttles, stop reason. Written with O_APPEND so OpenEvolve's worker processes share one file. Default location <output_dir>/bedrock_ledger.jsonl. |
| Cost and $/result | oe-bedrock cost prices the ledger from a pricing.yaml you fill from the Bedrock pricing page. --threshold X --metric combined_score finds the first checkpoint that reached X and reports spend up to that point. |
Install
pip install openevolve-bedrock # or: pip install -e . from a checkout
cp $(python -c 'import openevolve_bedrock,os;print(os.path.dirname(openevolve_bedrock.__file__))')/pricing.example.yaml pricing.yaml
Fill pricing.yaml (USD per 1K tokens; cross-region prefixes us./eu./… are
matched automatically, but us. and global. profiles are priced differently,
so key the exact id to price it exactly). Prices are not shipped because they
change; the AWS Price List API (AmazonBedrockFoundationModels) has them per
region. The tool reports any model without input/output prices; empty
cache_read/cache_write count as 0.
Credentials: whatever boto3 finds (AWS_PROFILE, instance role, SSO), or a
Bedrock API key in AWS_BEARER_TOKEN_BEDROCK. The https:// transport needs a
Bedrock API key; without one it signs short-term keys from the boto3
credentials (as aws-bedrock-token-generator does) and re-signs them every
15 minutes. Region from api_base,
OE_BEDROCK_REGION, or AWS_REGION.
Run
oe-bedrock models --profiles # text models, profiles, lifecycle (LEGACY ...)
oe-bedrock models --profiles --vendor mistral # one vendor
oe-bedrock check --config config.yaml # one short call per model
oe-bedrock check --config config.yaml --cache-probe # ~5K-token system prompt twice: does the 2nd read the cache?
oe-bedrock run initial_program.py evaluator.py --config config.yaml --iterations 100
oe-bedrock cost openevolve_output/ --pricing pricing.yaml
Stopping early
--target-score Tis OpenEvolve's own: stop once a program'scombined_scorereaches T.--budget-usd X --pricing pricing.yamlstops once the run's ledger, priced with that file, reaches $X. It is checked before each new iteration is submitted. Iterations already in flight finish and are recorded, so the overshoot is at most2 × parallel_evaluationscalls. Every model in the config must have a price, or the run refuses to start. Also settable asOE_BEDROCK_BUDGET_USD/OE_BEDROCK_PRICING.
After either stop, the last checkpoint is the iteration where the run
stopped. On its own, OpenEvolve labels its final checkpoint with the maximum
iteration (checkpoint_100 for a run that stopped at 57). OpenEvolve then logs
"stopped due to shutdown request", which is expected.
oe-bedrock run is OpenEvolve's own CLI with the provider registered and the
ledger pointed at the output directory; extra flags pass through. The Python API works
too — importing the package is the registration:
import openevolve_bedrock # registers provider: bedrock
from openevolve import OpenEvolve
If you launch OpenEvolve some other way (openevolve-run.py, your own script)
and use process-parallel workers under the spawn start method (macOS default),
the workers must import this package too. Either put import openevolve_bedrock
at the top of the script that is __main__, or run oe-bedrock install-hook
once to add a .pth file that imports it in every interpreter of that environment.
Mantle vs. Converse
Both endpoints bill the same per token. They differ in how throughput is
managed: bedrock-runtime has per-account RPM/TPM quotas; Mantle schedules and
queues for fair share with higher initial throughput, which suits the bursty
fan-out of island-parallel evolution. To compare on your account:
llm:
provider: bedrock
api_base: https://bedrock-mantle.us-west-2.api.aws/v1
# api_key: "${AWS_BEARER_TOKEN_BEDROCK}" # optional; else minted from AWS credentials
Everything else stays the same. cost reports throttles per run, so the
comparison is wall-clock and throttle count at fixed parallel_evaluations.
The transport is chosen per model, so one ensemble can mix them. Set
api_base on a model to override the llm-level one:
llm:
provider: bedrock
api_base: aws://us-west-2 # default: Converse
models:
- name: us.anthropic.claude-haiku-5-5 # Converse
weight: 0.6
- name: us.openai.gpt-6.1-sol # bedrock-runtime Chat Completions
weight: 0.2
api_base: https://bedrock-runtime.us-west-2.amazonaws.com/openai/v1
- name: openai.gpt-oss-120b # Mantle Chat Completions
weight: 0.2
api_base: https://bedrock-mantle.us-west-2.api.aws/v1
All three share one set of AWS credentials and one ledger; cost breaks the
run down per model.
Notes on the OpenAI-compatible endpoints, from the Bedrock endpoint docs and live runs (2026-10-28):
- AWS recommends
https://bedrock-runtime.<region>.amazonaws.com/openai/v1for Chat Completions. It takes cross-region ids (us.openai.gpt-6.1-sol) and versioned ids (openai.gpt-oss-120b-1:0), but has noGET /models. - Mantle has no cross-region profiles; ids are unversioned
(
openai.gpt-oss-120b) andGET /v1/modelslists them. Its base path varies by model: most are under/v1, some (GPT-6.1 Sol) under/openai/v1, and the wrong one answers "isn't supported on this route". Each model card's Programmatic Access table gives the URL. Claude isn't served on Mantle's Chat Completions; use Converse. - Mantle needs IAM
bedrock-mantle:CreateInference;bedrock-runtimeneedsbedrock:InvokeModel. - Prompt caching depends on the model. GPT-5.6 and later cache automatically
(1,024-token minimum) and report
prompt_tokens_details.cached_tokensandcache_write_tokens; the ledger records both. gpt-oss, Qwen, GLM and Devstral report no cache usage. - On
bedrock-runtime, gpt-oss returns its reasoning inline incontentas a leading<reasoning>…</reasoning>span; the provider strips it.
Experiments the ledger is built for
bench/matrix.py runs one problem under several ensemble mixes and seeds,
checkpointing every 5 iterations, and writes two CSVs under --out:
results.csv, a row per run: configured and realized mix,best@N, then for each--thresholdthe iteration and $ at which it was first reached (blank if never), then $ total, calls, throttles and wall time.curves.csv, a row per checkpoint per run: best-so-far, cumulative $ and calls, seconds since the first call. This is the $/result curve: what each extra dollar bought, which no single threshold shows.
python bench/matrix.py examples/circle_packing --pricing pricing.yaml \
--iterations 100 --threshold 0.99 0.995 0.999 --seeds 1 2 3 \
--variant fast-only "haiku:1.0" \
--variant gpt-oss "gpt-oss:1.0" \
--variant 80-20 "haiku:0.8,sonnet:0.2" \
--variant 50-50 "haiku:0.5,sonnet:0.5"
Thresholds only affect scoring. Both CSVs are rebuilt from every run dir
under --out, so --rescore re-scores finished runs at other thresholds
without calling Bedrock. --target-score and --budget-usd are passed to
every run. A finished run is reused, so an interrupted matrix resumes; an
interrupted run's dir is moved aside (*.interrupted-<time>) and rerun from
scratch. In --variant, a model id that contains :
needs an explicit weight (openai.gpt-oss-120b-1:0:1.0); aliases don't.
Three measurements this makes cheap:
- Ensemble mix — the paper's fast-heavy/strong-light split against all-fast
and 50/50, on iterations-to-threshold and $. OpenEvolve 0.4.0 seeds every
worker's ensemble RNG identically, so all workers draw the same model
sequence (openevolve#554).
OpenEvolve 0.4.1 reseeds per iteration itself (
LLMEnsemble.reseed). On 0.4.0 this package does the same from(llm_seed, iteration). Either way, runs are reproducible with independent draws. Therealized_mixcolumn still reports what each run actually got: with 100 iterations a 0.2 weight can land anywhere from roughly 0.12 to 0.28. - Endpoint — same config with
--api-baseset to the Mantle URL; compare throttles and wall-clock at the same island parallelism. - Open-weight on Bedrock vs. local — gpt-oss-120b ships its weights in
MXFP4, so Bedrock and a local server run the same weights and the
comparison is $/result and wall time alone, with no quantization
difference. Run it fast-only (
gpt-oss:1.0) against Haiku fast-only to isolate the model. The local side is any OpenAI-compatible server (vLLM, llama.cpp) via a plainapi_base.
combined_score for circle packing is sum_radii / 2.635, so --threshold 0.99
is 2.609, 0.995 is 2.622 and 1.0 is the AlphaEvolve figure.
Configuration reference
| key | meaning |
|---|---|
llm.provider: bedrock |
required; may be set per model instead |
llm.api_base |
aws://<region> (Converse) or an https:// OpenAI-compatible Bedrock endpoint |
llm.api_key |
Bedrock API key for the https:// transport; "${VAR}" is resolved from the environment |
llm.models[].name |
model id or inference-profile id (us., eu., global. …) |
llm.models[].api_base, .api_key |
per-model override, e.g. to mix Converse and OpenAI-compatible models in one ensemble |
temperature, top_p, max_tokens, timeout, reasoning_effort |
as in OpenEvolve; retries/retry_delay are superseded by OE_BEDROCK_MAX_ATTEMPTS |
| environment | meaning |
|---|---|
OE_BEDROCK_REGION, OE_BEDROCK_PROFILE |
default region; boto3 profile |
OE_BEDROCK_CACHE |
auto (default) or off |
OE_BEDROCK_LEDGER |
ledger path, or off |
OE_BEDROCK_MAX_ATTEMPTS |
retry budget for throttles/transient errors (default 8) |
OE_BEDROCK_THINKING_BUDGET |
enable Claude extended thinking with this token budget |
OE_BEDROCK_BUDGET_USD, OE_BEDROCK_PRICING |
stop the run at this spend, priced with this file (same as run --budget-usd --pricing) |
AWS_BEARER_TOKEN_BEDROCK |
Bedrock API key (both transports; optional for https://, which can mint one) |
OE_BEDROCK_FITNESS_INTEGRITY |
1: an evaluator failure (the evaluator sets evaluator_failed: 1.0) is retried and never archived as a score; every attempt's outcome goes to the ledger (#47). Off by default |
OE_BEDROCK_EVAL_RETRIES |
retries for an evaluator failure before the candidate is skipped (default 2) |
OE_BEDROCK_SELFTEST |
1: run first checks the evaluator against its reference, null and planted candidates and aborts if any check fails (#48). Off by default |
OE_BEDROCK_SELFTEST_DIR |
planted directory (default selftest/ next to the evaluator) |
OE_BEDROCK_OUTCOMES |
1: log each evaluation's outcome and code hash to the ledger without retrying or skipping (used by compare; behaviour unchanged) |
Measurement helpers
Both are off by default, so stock OpenEvolve behaviour is unchanged.
-
Fitness integrity (
OE_BEDROCK_FITNESS_INTEGRITY=1). Classifies each evaluation asscored,candidate_failedorevaluator_failed. A lost pool worker or a GPU host with no answer would otherwise be archived as a candidate scoring 0. -
Self-test (
oe-bedrock selftest INITIAL EVALUATOR, orOE_BEDROCK_SELFTEST=1onrun). Runs before any search:- the reference program must score. That is
reference.pyin the planted directory if present, else the initial program; - every
null*.pyand planted*.pymust fail.
It reports the evaluator's false-accept rate. Planted sets ship for the stand-in,
qiskit_routingand KernelBenchlevel1/19_ReLU. - the reference program must score. That is
-
Verify (
oe-bedrock verify OUTPUT_DIR --evaluator EVAL [--top 4] [--seeds 0,1,2,3] [--initial PROG]). Re-scores the run's top distinct programs, and the initial program, through the evaluator'sevaluate_heldout(program_path, seed). Reports:- the training score;
- the held-out score per seed;
- the held-out mean, with a 95% t-interval across seeds;
- the shrinkage, held-out mean minus training score.
A program that fails held-out correctness is marked rejected. The stand-in and
qiskit_routingdefine the hook. On #30's 200-iteration Qiskit run, it reproduces the hand-computed result: the winner goes from 1.020 on training to 1.005 on held-out (#41). -
Nulls (
oe-bedrock nulls INITIAL EVALUATOR [--seeds 0,1,2,3] [--replicates 4] [--bar-k 2] --out nulls.json). The two numbers a held-out claim has to clear (#42):- the seed null: the range of held-out means of programs that make no real change, the initial program included. The replicates come from the evaluator's optional
evaluate_null(program_path, seed, replicate), or else the initial program at shifted seeds; - the compute-matched bar: best-of-k of the initial program at k times its cost, from the optional
evaluate_bar(program_path, seed, k).
verify --nulls nulls.jsonmarks each program above or inside the null, and above, inside or below each bar. The bar verdict uses a paired 95% interval over the same seeds.qiskit_routingdefines both hooks: transpiler seed + 100·(r+1) for the null, and the fewest-CZ output over k seeds for the bar. - the seed null: the range of held-out means of programs that make no real change, the initial program included. The replicates come from the evaluator's optional
-
Compare (
oe-bedrock compare arms.yaml --out DIR). Runs named arms at equal budget, the same iterations and seeds, where arms differ only by config file and environment. An arm withkind: bestofnmakes the same number of LLM calls as independent samples from the initial program, with no population (oe-bedrock bestofn). Each winner is verified on held-out data.One table per arm, mean ± sd over seeds:
- best training score and held-out score;
- the winners' held-out metrics listed under
report:(defaultcpu_ratio, shown when the evaluator returns it); - verified rate, and with
nulls:the share of winners above the seed null and above each bar; - LLM calls and $, and $ per verified improvement;
- duplicate rate and repeat-failure rate.
Format:
openevolve_bedrock.compare. On the stand-in, 2 arms × 3 seeds × 60 iterations take about 9 s (#53). -
Stand-in (
openevolve_bedrock.standin). A CPU evaluator plusprovider: oeb-fake, for developing and A/B-testing these with no AWS account:- a known optimum of 1.821;
- 1% seeded noise;
- injectable faults (
STANDIN_FAULT_RATE); - planted defects.
100 iterations take about 1 s.
Tests
pip install -e ".[dev]"
pytest # ~160 tests, ~30 s, no AWS credentials needed
tests/test_e2e_spawn.py runs a real 40-iteration OpenEvolve job twice with
process-parallel workers under the spawn start method against a fake Mantle
server that returns programs, reports usage and throws 429s at random — the
case that matters for macOS users and for the retry path. It asserts that
per-model call counts match the per-iteration seeding exactly and repeat
across runs.
Not in scope (yet)
- Evaluator fan-out to EC2. OpenEvolve's
evaluate()runs in local worker processes; for expensive evaluators the next step is a shim that ships candidates to a pool and returns metrics. The ledger already separates token cost from everything else so the two tiers can be reported side by side. - Bedrock batch inference. The loop is latency-bound per iteration, so batch jobs don't fit without restructuring generation into offline waves.
License
Apache License 2.0 — Copyright 2026 Scott Friedman. OpenEvolve and the example
problems are Apache-2.0, Copyright Asankhaya Sharma; see NOTICE.
Metadata
Release files for openevolve-bedrock 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| openevolve_bedrock-0.3.0.tar.gz | 103.3 kB | With provenance | Details for openevolve_bedrock-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| openevolve_bedrock-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for openevolve_bedrock-0.3.0-py3-none-any.whl |
Total release size: 184.0 kB
Release files / openevolve_bedrock-0.3.0.tar.gz
| Download URL | openevolve_bedrock-0.3.0.tar.gz |
|---|---|
| Size | 103.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c858d58ebbc9f74a38b77dee8110327b1021af39e93e137ba3aaded9822018c7
|
|
BLAKE2b-256 checksum How to use checksums |
974dc731da4b93d8c6bc5bdc109af4ae3395970d3db9cf6f459552a4ece71e43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / openevolve_bedrock-0.3.0-py3-none-any.whl
| Download URL | openevolve_bedrock-0.3.0-py3-none-any.whl |
|---|---|
| Size | 80.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b66485d973364f18b67b97eaed4608b604d3a9149b28d42845c387f4749b43c4
|
|
BLAKE2b-256 checksum How to use checksums |
eb1b5aa97d272b57d1d5a91e2d676f26db0d7cfd90316db44108a3a3b632a3e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logSecurity for openevolve-bedrock 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for openevolve_bedrock-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.