agentplaykit 0.1.1__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/CHANGELOG.md +23 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/PKG-INFO +9 -8
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/README.md +8 -7
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/adr/0003-model-neutral.md +1 -1
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/adr/0004-no-built-in-prices.md +1 -1
- agentplaykit-0.2.0/docs/adr/0005-provider-presets.md +33 -0
- agentplaykit-0.2.0/docs/guides/models.md +146 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/guides/scenarios.md +3 -2
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/quickstart.md +3 -5
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/tutorials/evaluate.md +1 -1
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/mkdocs.yml +1 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/SPEC-009-adapters.md +34 -7
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/__init__.py +1 -1
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/agents/_http.py +11 -6
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/agents/config.py +9 -4
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/agents/openai_compat.py +68 -16
- agentplaykit-0.2.0/src/agentplaykit/agents/providers.py +96 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/registry/__init__.py +28 -1
- agentplaykit-0.2.0/tests/conformance/test_presets.py +258 -0
- agentplaykit-0.1.1/docs/guides/models.md +0 -92
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/.claude/hooks/session-start.sh +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/.claude/settings.json +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/.github/CODEOWNERS +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/.github/ISSUE_TEMPLATE/bug.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/.github/ISSUE_TEMPLATE/spec-proposal.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/.github/ISSUE_TEMPLATE/world-request.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/.github/workflows/ci.yml +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/.github/workflows/docs.yml +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/.github/workflows/release.yml +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/.gitignore +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/.pre-commit-config.yaml +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/CLAUDE.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/CODE_OF_CONDUCT.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/CONTRIBUTING.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/GOVERNANCE.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/LICENSE +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/MAINTAINERS.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/SECURITY.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/adr/0000-template.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/adr/0001-name-and-package-name.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/adr/0002-tooling-and-defaults.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/development-plan.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/guides/cli.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/guides/run-log.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/index.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/release-checklist.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/security-review.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/tutorials/write-a-world.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/docs/tutorials/write-an-agent.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/examples/command-agent/my_agent.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/examples/command-agent/scenario.yaml +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/examples/guess/bisect_agent.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/examples/guess/guess_world.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/examples/guess/scenario.yaml +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/examples/ox-chat/scenario.yaml +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/examples/ox-llm/scenario.yaml +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/examples/ox_demo.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/examples/treasure/scenario.yaml +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/examples/treasure/treasure_checker.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/examples/treasure/treasure_world.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/pyproject.toml +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/scripts/check_boundaries.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/scripts/check_licenses.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/scripts/check_spdx.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/scripts/check_spec_links.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/scripts/mkdocs_hooks.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/SPEC-000-process.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/SPEC-001-environment.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/SPEC-002-agent.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/SPEC-003-run-log.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/SPEC-004-runner.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/SPEC-005-scenario.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/SPEC-006-registry.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/SPEC-007-cli.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/SPEC-008-message-bus.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/SPEC-010-evaluators.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/SPEC-011-security.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/TEMPLATE.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/schemas/evalresult.schema.json +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/schemas/runlog.schema.json +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/schemas/scenario.schema.json +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/specs/untested.yaml +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/__main__.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/agents/__init__.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/agents/anthropic_agent.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/agents/command.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/agents/http_agent.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/agents/mcp_agent.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/agents/pricing.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/agents/proc.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/agents/prompting.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/agents/scripted.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/cli/__init__.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/cli/main.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/core/__init__.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/core/agent.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/core/bus.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/core/environment.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/core/evaluator.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/core/log.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/core/plain.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/core/runner.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/envs/__init__.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/envs/blank.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/envs/ox.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/envs/rps.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/evals/__init__.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/evals/judge.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/evals/outcome.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/evals/summary.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/py.typed +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/scenario/__init__.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/scenarios/demo.yaml +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/schemas/evalresult.schema.json +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/schemas/runlog.schema.json +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/schemas/scenario.schema.json +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/src/agentplaykit/testkit.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/__init__.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/__init__.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/conftest.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/fakes.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/helpers.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/plugin_pkg.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_adapters.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_agent.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_cli.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_environment.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_evaluators.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_message_bus.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_registry.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_run_log.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_runner.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_scenario.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_schemas.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_security.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_specs.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/conformance/test_testkit.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/fixtures/providers/README.md +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/fixtures/providers/anthropic_refusal.json +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/fixtures/providers/anthropic_text.json +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/fixtures/providers/anthropic_tool_use.json +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/fixtures/providers/openai_chat_no_usage.json +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/fixtures/providers/openai_chat_text.json +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/fixtures/providers/openai_chat_tool.json +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/fixtures/sample_run.jsonl +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/fixtures/sample_scenario.yaml +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/golden/ox_minimax_vs_random_seed7.jsonl +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/live/__init__.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/live/test_live_adapters.py +0 -0
- {agentplaykit-0.1.1 → agentplaykit-0.2.0}/tests/test_smoke.py +0 -0
|
@@ -6,6 +6,29 @@ Format: [Keep a Changelog](https://keepachangelog.com/). Versioning: [SemVer](ht
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.2.0] - 2026-11-30
|
|
10
|
+
|
|
11
|
+
Named setups for common model services ([ADR-0005](docs/adr/0005-provider-presets.md)).
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- Provider presets: `use: openai`, `openrouter`, `groq`, `deepseek`, `gemini`, `mistral`,
|
|
15
|
+
`together` and `ollama`. Each fills in the service's address and key variable, so `model` is
|
|
16
|
+
all you need; any default can be overridden (ADP-020). A missing key stops the run before
|
|
17
|
+
any request and names the variable to export (ADP-021).
|
|
18
|
+
- `openrouter` logs the actual cost OpenRouter reports for each call, so `price` is optional
|
|
19
|
+
there (ADP-022). Attribution headers are sent only when you set `app_name` / `app_url`
|
|
20
|
+
(ADP-023).
|
|
21
|
+
- `ollama` needs no key, costs 0, and says to run `ollama serve` when the server is not
|
|
22
|
+
running (ADP-024).
|
|
23
|
+
- Hosted presets never count as free, even through a proxy on `localhost`, so budget caps keep
|
|
24
|
+
applying; set `local: true` to opt out.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- `openai_compat` is now the generic adapter for servers without a preset (LM Studio, vLLM,
|
|
28
|
+
llama.cpp, proxies). Existing scenarios using it keep working unchanged.
|
|
29
|
+
- The log's `provider` for a preset is the preset name (for example `openrouter`) instead of
|
|
30
|
+
the URL's host.
|
|
31
|
+
|
|
9
32
|
## [0.1.1] - 2026-11-30
|
|
10
33
|
|
|
11
34
|
Fixes from trying v0.1.0 with free hosted models and on Windows.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: agentplaykit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A framework for putting AI agents into worlds, letting them act and talk, and scoring and logging what happens.
|
|
5
5
|
Project-URL: Homepage, https://github.com/thetejasmagade/agentplay
|
|
6
6
|
Project-URL: Documentation, https://agentplay.itejas.dev/
|
|
@@ -80,27 +80,28 @@ Any model can play, hosted or local. Change the agent's `use` line:
|
|
|
80
80
|
|
|
81
81
|
| `use` | Connects to |
|
|
82
82
|
|---|---|
|
|
83
|
-
| `
|
|
83
|
+
| `openai`, `openrouter`, `groq`, `deepseek`, `gemini`, `mistral`, `together` | That hosted service; only `model` is needed, the key comes from its usual variable (`OPENROUTER_API_KEY`, ...) |
|
|
84
|
+
| `ollama` | A local Ollama server: free, no key |
|
|
85
|
+
| `openai_compat` | Any other OpenAI-compatible server (LM Studio, vLLM, llama.cpp, proxies) via `base_url` |
|
|
84
86
|
| `anthropic` | Claude via the Anthropic SDK (`pip install "agentplaykit[anthropic]"`) |
|
|
85
87
|
| `command` | Any program, in any language, reading and writing JSON lines |
|
|
86
88
|
| `http` | Any agent behind a URL |
|
|
87
89
|
| `mcp` | A tool on an MCP server (`pip install "agentplaykit[mcp]"`, Python 3.10+) |
|
|
88
90
|
|
|
89
91
|
```yaml
|
|
90
|
-
- id: x
|
|
91
|
-
|
|
92
|
-
config: {base_url: "http://localhost:11434/v1", model: "llama3.2"} # local Ollama, free
|
|
92
|
+
- {id: x, use: ollama, config: {model: "llama3.2"}} # local, free
|
|
93
|
+
- {id: y, use: openrouter, config: {model: "<provider>/<model>"}} # key from OPENROUTER_API_KEY
|
|
93
94
|
```
|
|
94
|
-
Keys come from environment variables
|
|
95
|
+
Keys come from environment variables, never from the scenario.
|
|
95
96
|
Every call's tokens and cost are logged; runs stop at `max_cost_usd` (default $1). Set `price`
|
|
96
|
-
per model for exact costs. See `examples/ox-llm/scenario.yaml` and `examples/command-agent/`.
|
|
97
|
+
per model for exact costs (`openrouter` reports its own). See `examples/ox-llm/scenario.yaml` and `examples/command-agent/`.
|
|
97
98
|
|
|
98
99
|
## Score and compare
|
|
99
100
|
Add evaluators to a scenario; they read only the finished log, so agents can never touch them:
|
|
100
101
|
```yaml
|
|
101
102
|
evaluators:
|
|
102
103
|
- {use: outcome, config: {agent: x}} # did x win?
|
|
103
|
-
- {use: judge, config: {rubric: "Did x explain its moves?", agent: {use:
|
|
104
|
+
- {use: judge, config: {rubric: "Did x explain its moves?", agent: {use: openrouter, config: {...}}}}
|
|
104
105
|
```
|
|
105
106
|
Run many seeds and get a summary (pass rate, steps, cost, spread):
|
|
106
107
|
```bash
|
|
@@ -40,27 +40,28 @@ Any model can play, hosted or local. Change the agent's `use` line:
|
|
|
40
40
|
|
|
41
41
|
| `use` | Connects to |
|
|
42
42
|
|---|---|
|
|
43
|
-
| `
|
|
43
|
+
| `openai`, `openrouter`, `groq`, `deepseek`, `gemini`, `mistral`, `together` | That hosted service; only `model` is needed, the key comes from its usual variable (`OPENROUTER_API_KEY`, ...) |
|
|
44
|
+
| `ollama` | A local Ollama server: free, no key |
|
|
45
|
+
| `openai_compat` | Any other OpenAI-compatible server (LM Studio, vLLM, llama.cpp, proxies) via `base_url` |
|
|
44
46
|
| `anthropic` | Claude via the Anthropic SDK (`pip install "agentplaykit[anthropic]"`) |
|
|
45
47
|
| `command` | Any program, in any language, reading and writing JSON lines |
|
|
46
48
|
| `http` | Any agent behind a URL |
|
|
47
49
|
| `mcp` | A tool on an MCP server (`pip install "agentplaykit[mcp]"`, Python 3.10+) |
|
|
48
50
|
|
|
49
51
|
```yaml
|
|
50
|
-
- id: x
|
|
51
|
-
|
|
52
|
-
config: {base_url: "http://localhost:11434/v1", model: "llama3.2"} # local Ollama, free
|
|
52
|
+
- {id: x, use: ollama, config: {model: "llama3.2"}} # local, free
|
|
53
|
+
- {id: y, use: openrouter, config: {model: "<provider>/<model>"}} # key from OPENROUTER_API_KEY
|
|
53
54
|
```
|
|
54
|
-
Keys come from environment variables
|
|
55
|
+
Keys come from environment variables, never from the scenario.
|
|
55
56
|
Every call's tokens and cost are logged; runs stop at `max_cost_usd` (default $1). Set `price`
|
|
56
|
-
per model for exact costs. See `examples/ox-llm/scenario.yaml` and `examples/command-agent/`.
|
|
57
|
+
per model for exact costs (`openrouter` reports its own). See `examples/ox-llm/scenario.yaml` and `examples/command-agent/`.
|
|
57
58
|
|
|
58
59
|
## Score and compare
|
|
59
60
|
Add evaluators to a scenario; they read only the finished log, so agents can never touch them:
|
|
60
61
|
```yaml
|
|
61
62
|
evaluators:
|
|
62
63
|
- {use: outcome, config: {agent: x}} # did x win?
|
|
63
|
-
- {use: judge, config: {rubric: "Did x explain its moves?", agent: {use:
|
|
64
|
+
- {use: judge, config: {rubric: "Did x explain its moves?", agent: {use: openrouter, config: {...}}}}
|
|
64
65
|
```
|
|
65
66
|
Run many seeds and get a summary (pass rate, steps, cost, spread):
|
|
66
67
|
```bash
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# ADR-0005: Built-in provider presets
|
|
2
|
+
- Status: Accepted
|
|
3
|
+
- Date: 2026-11-30
|
|
4
|
+
- Amends: [ADR-0003](0003-model-neutral.md), [ADR-0004](0004-no-built-in-prices.md)
|
|
5
|
+
|
|
6
|
+
## Context
|
|
7
|
+
In v0.1 every OpenAI-compatible service went through one adapter, `openai_compat`. Users had to
|
|
8
|
+
know each service's URL, key variable and quirks, and nothing service-specific was possible:
|
|
9
|
+
OpenRouter could not report the cost it actually charged, and a stopped Ollama gave a generic
|
|
10
|
+
"is the server running?" error.
|
|
11
|
+
|
|
12
|
+
## Decision
|
|
13
|
+
- Ship named presets as built-in adapters: `openai`, `openrouter`, `groq`, `deepseek`, `gemini`,
|
|
14
|
+
`mistral`, `together` (hosted) and `ollama` (local).
|
|
15
|
+
- All presets are rows in one table (`agentplaykit/agents/providers.py`) over the shared
|
|
16
|
+
OpenAI-compatible code. A preset only fills in defaults (`base_url`, `api_key_env`); config
|
|
17
|
+
can override any of them.
|
|
18
|
+
- `openai_compat` stays as the generic adapter for every other OpenAI-compatible server.
|
|
19
|
+
`anthropic` and `mcp` are unchanged.
|
|
20
|
+
- Every preset keeps plain-text replies by default, so all models get the same prompt (ADP-003).
|
|
21
|
+
- When a provider reports the cost it charged for a call (OpenRouter), that cost is used if the
|
|
22
|
+
config sets no `price`. This is a measured value, not a guess, so ADR-0004's rule against
|
|
23
|
+
built-in prices still holds.
|
|
24
|
+
- A hosted preset is never treated as a free local endpoint, even through a proxy on
|
|
25
|
+
`localhost`, unless config sets `local: true`; otherwise budget caps could silently stop
|
|
26
|
+
applying.
|
|
27
|
+
- OpenRouter attribution headers are sent only when config sets `app_name` or `app_url`.
|
|
28
|
+
|
|
29
|
+
## Consequences
|
|
30
|
+
Most users get a one-line setup (`use: openrouter`, `model: ...`). The core still names no
|
|
31
|
+
vendor: presets live in `agents/` and are ordinary built-in adapters (ADP-001). Adding another
|
|
32
|
+
OpenAI-compatible service is one row in the table plus a test. Services that are not
|
|
33
|
+
OpenAI-compatible still ship as plugins (ADP-005).
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Real AI models
|
|
2
|
+
|
|
3
|
+
AgentPlay is model-neutral ([ADR-0003](../adr/0003-model-neutral.md)): no vendor is built
|
|
4
|
+
into the core, and every model gets the same prompt.
|
|
5
|
+
|
|
6
|
+
| `use` | Connects to | Install |
|
|
7
|
+
| --- | --- | --- |
|
|
8
|
+
| `openai` | OpenAI | included |
|
|
9
|
+
| `openrouter` | Hundreds of hosted models through [OpenRouter](https://openrouter.ai) | included |
|
|
10
|
+
| `groq`, `deepseek`, `gemini`, `mistral`, `together` | That hosted service | included |
|
|
11
|
+
| `ollama` | A local [Ollama](https://ollama.com) server | included |
|
|
12
|
+
| `openai_compat` | Any other OpenAI-compatible server: LM Studio, vLLM, llama.cpp, proxies | included |
|
|
13
|
+
| `anthropic` | Claude, through the official SDK | `pip install "agentplaykit[anthropic]"` |
|
|
14
|
+
| `command` | Any program speaking JSON lines | included |
|
|
15
|
+
| `http` | Any agent behind a URL | included |
|
|
16
|
+
| `mcp` | A tool on an MCP server | `pip install "agentplaykit[mcp]"` (Python 3.10+) |
|
|
17
|
+
|
|
18
|
+
## Provider presets
|
|
19
|
+
|
|
20
|
+
Each named service is a preset: it fills in the address and the key variable, so `model` is
|
|
21
|
+
all you need ([ADR-0005](../adr/0005-provider-presets.md)).
|
|
22
|
+
|
|
23
|
+
| `use` | Default `base_url` | Key variable |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| `openai` | `https://api.openai.com/v1` | `OPENAI_API_KEY` |
|
|
26
|
+
| `openrouter` | `https://openrouter.ai/api/v1` | `OPENROUTER_API_KEY` |
|
|
27
|
+
| `groq` | `https://api.groq.com/openai/v1` | `GROQ_API_KEY` |
|
|
28
|
+
| `deepseek` | `https://api.deepseek.com/v1` | `DEEPSEEK_API_KEY` |
|
|
29
|
+
| `gemini` | `https://generativelanguage.googleapis.com/v1beta/openai` | `GEMINI_API_KEY` |
|
|
30
|
+
| `mistral` | `https://api.mistral.ai/v1` | `MISTRAL_API_KEY` |
|
|
31
|
+
| `together` | `https://api.together.xyz/v1` | `TOGETHER_API_KEY` |
|
|
32
|
+
| `ollama` | `http://localhost:11434/v1` | none |
|
|
33
|
+
|
|
34
|
+
```yaml
|
|
35
|
+
- id: x
|
|
36
|
+
use: groq
|
|
37
|
+
config:
|
|
38
|
+
model: "<model id from the provider's model list>"
|
|
39
|
+
price: {input_per_mtok: 0.5, output_per_mtok: 1.5} # the model's listed prices
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
- If the key variable is not set, the run stops before any request and says which variable
|
|
43
|
+
to export.
|
|
44
|
+
- Every preset takes all the `openai_compat` options below. Override `base_url` to go through a
|
|
45
|
+
proxy, `api_key_env` to read a different variable, or `api_key_env: null` to send no key.
|
|
46
|
+
- A hosted preset is never counted as free, even through a proxy on `localhost`, so budget
|
|
47
|
+
caps keep working. Set `price`, or `local: true` if the calls really cost nothing.
|
|
48
|
+
- The log records the preset name as the provider (override with `provider`).
|
|
49
|
+
- Replies are plain JSON text by default, the same for every model, so comparisons are fair.
|
|
50
|
+
Set `tool_calls: true` to use native tool calls.
|
|
51
|
+
|
|
52
|
+
## OpenRouter
|
|
53
|
+
|
|
54
|
+
OpenRouter gives one key for hundreds of hosted models:
|
|
55
|
+
|
|
56
|
+
```yaml
|
|
57
|
+
- id: x
|
|
58
|
+
use: openrouter
|
|
59
|
+
config:
|
|
60
|
+
model: "<provider>/<model>" # copy the exact id from openrouter.ai/models
|
|
61
|
+
app_name: "My benchmark" # optional: sent as X-Title
|
|
62
|
+
app_url: "https://example.org" # optional: sent as HTTP-Referer
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- **Cost is recorded for you.** AgentPlay asks OpenRouter for each call's actual cost and logs
|
|
66
|
+
it, so `price` is optional here. A `price` you set still wins.
|
|
67
|
+
- Nothing identifies your app unless you set `app_name` / `app_url` (OpenRouter uses them for
|
|
68
|
+
its app rankings).
|
|
69
|
+
- Pick a **chat (text to text)** model. Embedding models (often with `embed` in the name)
|
|
70
|
+
cannot play: every request is refused and runs end as `aborted`.
|
|
71
|
+
- Models ending in `:free` cost nothing but have tight rate limits. Many games in a row hit
|
|
72
|
+
`429` errors; the multi-run summary lists them under `errors:`. Run fewer games, wait
|
|
73
|
+
between batches, or raise `retries`.
|
|
74
|
+
- `usage` events record the model OpenRouter actually served, so you can see if it routed you
|
|
75
|
+
elsewhere.
|
|
76
|
+
|
|
77
|
+
## Ollama
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
- {id: x, use: ollama, config: {model: "llama3.2"}} # run `ollama pull llama3.2` first
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
No key, and cost is 0 on this machine. If Ollama is not running, the error says to start it
|
|
84
|
+
with `ollama serve`. For Ollama on another machine, set `base_url: "http://<host>:11434/v1"`
|
|
85
|
+
and `local: true` to keep it free; otherwise its cost is unknown and the token cap applies.
|
|
86
|
+
|
|
87
|
+
## `openai_compat`
|
|
88
|
+
|
|
89
|
+
For any other server that speaks the OpenAI chat format (LM Studio, vLLM, llama.cpp, a proxy):
|
|
90
|
+
|
|
91
|
+
```yaml
|
|
92
|
+
- id: x
|
|
93
|
+
use: openai_compat
|
|
94
|
+
config:
|
|
95
|
+
base_url: "http://localhost:1234/v1" # required
|
|
96
|
+
model: "local-model" # required
|
|
97
|
+
api_key_env: MY_API_KEY # only if the server needs a key
|
|
98
|
+
price: {input_per_mtok: 0.5, output_per_mtok: 1.5}
|
|
99
|
+
tool_calls: false # default: the model answers with JSON text, which every server supports
|
|
100
|
+
json_mode: false
|
|
101
|
+
temperature: 0.2 # sent only if set
|
|
102
|
+
max_output_tokens: 1024
|
|
103
|
+
timeout_s: 120
|
|
104
|
+
retries: 5 # default; about 30 s of backoff for rate limits
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## `anthropic`
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
- id: x
|
|
111
|
+
use: anthropic
|
|
112
|
+
config:
|
|
113
|
+
model: claude-opus-5-5
|
|
114
|
+
api_key_env: ANTHROPIC_API_KEY
|
|
115
|
+
price: {input_per_mtok: 4.0, output_per_mtok: 20.0}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
It lets the model choose to call the `act` tool (`tool_choice: auto`), sends no sampling
|
|
119
|
+
parameters unless you set them, and reports a refusal as an agent error.
|
|
120
|
+
|
|
121
|
+
## Costs and budgets
|
|
122
|
+
|
|
123
|
+
- Every call's tokens and cost are logged, and runs stop at `limits.max_cost_usd`
|
|
124
|
+
(default $1).
|
|
125
|
+
- AgentPlay ships no price list ([ADR-0004](../adr/0004-no-built-in-prices.md)): set `price`
|
|
126
|
+
from your provider's current price list. The exception is `openrouter`, which reports each
|
|
127
|
+
call's actual cost.
|
|
128
|
+
- Local servers cost $0. Without a price, cost is unknown: the log gets a warning and
|
|
129
|
+
`limits.max_tokens` applies instead.
|
|
130
|
+
|
|
131
|
+
## Keys and safety
|
|
132
|
+
|
|
133
|
+
- Keys come only from environment variables (`api_key_env`), never from scenario files.
|
|
134
|
+
- Keys are redacted from logs, results and errors.
|
|
135
|
+
- Keys are never sent over plain `http://` to a remote host (override:
|
|
136
|
+
`allow_insecure_http: true`).
|
|
137
|
+
- Redirects are never followed, so a key only goes to the host you named.
|
|
138
|
+
- Agent programs (`command`, `mcp`) do not inherit your environment; forward variables with
|
|
139
|
+
`pass_env`.
|
|
140
|
+
|
|
141
|
+
## Retries
|
|
142
|
+
|
|
143
|
+
Rate limits and server errors are retried with backoff (`retries`, default 5: waits of 1, 2, 4, 8
|
|
144
|
+
and 16 seconds), honoring
|
|
145
|
+
`Retry-After`. Each retry is logged as a `provider_error`. If the provider stays down, the
|
|
146
|
+
run ends as `aborted`; this never counts as a forfeit.
|
|
@@ -11,7 +11,7 @@ seed: 7 # default 0
|
|
|
11
11
|
world: {use: ox, config: {}}
|
|
12
12
|
agents:
|
|
13
13
|
- {id: x, use: scripted/minimax}
|
|
14
|
-
- {id: o, use:
|
|
14
|
+
- {id: o, use: openrouter, config: {model: "..."}}
|
|
15
15
|
limits:
|
|
16
16
|
max_steps: 200 # defaults shown; null turns a limit off
|
|
17
17
|
max_seconds: 600
|
|
@@ -34,7 +34,8 @@ In this order; the first match wins:
|
|
|
34
34
|
3. An installed plugin (entry points `agentplaykit.envs`, `agentplaykit.agents`,
|
|
35
35
|
`agentplaykit.evaluators`).
|
|
36
36
|
4. A built-in: worlds `ox`, `blank`, `rps`; agents `scripted/random`, `scripted/minimax`,
|
|
37
|
-
`openai_compat`, `
|
|
37
|
+
`openai_compat`, `openai`, `openrouter`, `groq`, `deepseek`, `gemini`, `mistral`, `together`,
|
|
38
|
+
`ollama`, `anthropic`, `command`, `http`, `mcp`; evaluators `outcome`, `judge`.
|
|
38
39
|
|
|
39
40
|
`agentplaykit env list` shows the worlds available from the current folder.
|
|
40
41
|
|
|
@@ -75,15 +75,13 @@ agentplaykit play my-game.yaml
|
|
|
75
75
|
Change one line. With [Ollama](https://ollama.com) running locally (free, no key):
|
|
76
76
|
|
|
77
77
|
```yaml
|
|
78
|
-
- {id: x, use:
|
|
78
|
+
- {id: x, use: ollama, config: {model: "llama3.2"}}
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
Or a hosted
|
|
81
|
+
Or a hosted service, with its key in the usual environment variable (here `OPENROUTER_API_KEY`):
|
|
82
82
|
|
|
83
83
|
```yaml
|
|
84
|
-
- id: x
|
|
85
|
-
use: openai_compat
|
|
86
|
-
config: {base_url: "https://openrouter.ai/api/v1", model: "<provider>/<model>", api_key_env: OPENROUTER_API_KEY}
|
|
84
|
+
- {id: x, use: openrouter, config: {model: "<provider>/<model>"}}
|
|
87
85
|
```
|
|
88
86
|
|
|
89
87
|
See [Real AI models](guides/models.md) for every option.
|
|
@@ -28,7 +28,7 @@ evaluators:
|
|
|
28
28
|
- use: judge
|
|
29
29
|
config:
|
|
30
30
|
rubric: "Did x explain its moves clearly and stay polite in chat?"
|
|
31
|
-
agent: {use:
|
|
31
|
+
agent: {use: ollama, config: {model: "llama3.2"}}
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
Agents write the transcript, so the judge is told to treat it as data and ignore any
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# SPEC-009: Adapters
|
|
2
2
|
|
|
3
3
|
- **Status:** Implemented
|
|
4
|
-
- **Milestone:** M4
|
|
4
|
+
- **Milestone:** M4; presets in v0.2.0 (ADR-0005)
|
|
5
5
|
- **Owners:** lead maintainer
|
|
6
6
|
|
|
7
7
|
## 1. Purpose
|
|
@@ -11,6 +11,7 @@ AgentPlay is **model-neutral**: any AI agent can play, hosted or local, from any
|
|
|
11
11
|
- **Adapter:** an agent plugin that connects some kind of agent. **Generic adapter:** works with any agent speaking a common protocol. **Provider adapter:** wraps one vendor's SDK.
|
|
12
12
|
- **Local agent:** a model or program running on the user's machine or network, needing no cloud account.
|
|
13
13
|
- **Fixture:** a recorded provider response used offline in tests.
|
|
14
|
+
- **Preset:** a built-in adapter for one OpenAI-compatible service, defined as a row of defaults over `openai_compat` (ADR-0005). **Hosted preset:** a preset for a cloud service that needs an API key.
|
|
14
15
|
|
|
15
16
|
## 3. Requirements
|
|
16
17
|
### Neutrality
|
|
@@ -20,11 +21,12 @@ AgentPlay is **model-neutral**: any AI agent can play, hosted or local, from any
|
|
|
20
21
|
|
|
21
22
|
### Built-in adapters
|
|
22
23
|
- **ADP-004** The framework MUST ship these generic adapters, which need no vendor SDK:
|
|
23
|
-
- `openai_compat`: any OpenAI-compatible chat endpoint via `base_url
|
|
24
|
+
- `openai_compat`: any OpenAI-compatible chat endpoint via `base_url`, such as LM Studio, vLLM and llama.cpp, or any service without a preset. Implemented over plain HTTP (standard library).
|
|
25
|
+
- the provider presets of ADP-020, built on `openai_compat`.
|
|
24
26
|
- `command`: runs any local program, in any language, speaking JSON over stdin and stdout: one Request line in, one Reply line out. Wraps local CLIs and models, or custom agents.
|
|
25
27
|
- `http`: POSTs the Request as JSON to any URL and reads the Reply, for agents served by other processes or machines.
|
|
26
28
|
- `scripted/random` and `scripted/minimax`: deterministic from the seed, free (ADP-013).
|
|
27
|
-
- **ADP-005** The framework MUST ship these SDK-based adapters as optional extras, each one equal to any third-party adapter: `anthropic` (`agentplaykit[anthropic]`) and `mcp` (`agentplaykit[mcp]`). Further vendors (for example
|
|
29
|
+
- **ADP-005** The framework MUST ship these SDK-based adapters as optional extras, each one equal to any third-party adapter: `anthropic` (`agentplaykit[anthropic]`) and `mcp` (`agentplaykit[mcp]`). Further vendors whose API is not OpenAI-compatible (for example Bedrock) SHOULD be added as separate plugins through the `agentplaykit.agents` entry point (REG-002); OpenAI-compatible services MAY instead be added as presets (ADP-020).
|
|
28
30
|
- **ADP-006** A user MUST be able to write their own agent as a Python class or function (SPEC-002, AGT-011) and use it with no framework changes.
|
|
29
31
|
|
|
30
32
|
### Packaging
|
|
@@ -34,17 +36,36 @@ AgentPlay is **model-neutral**: any AI agent can play, hosted or local, from any
|
|
|
34
36
|
- **ADP-008** Adapter config MUST accept, where meaningful: `model`, `base_url`, `api_key_env` (env var name; optional, since local servers often need no key), `temperature`, `max_output_tokens`, `timeout_s`, `retries`, `command` / `url`.
|
|
35
37
|
- **ADP-009** Adapters MUST declare capabilities (AGT-006) and use native tool calls where supported, otherwise plain-text prompting with a strict parser; the log records which mode was used. Small local models without tool calls MUST work through the plain-text mode.
|
|
36
38
|
- **ADP-010** Replies MUST report `usage` and `meta.provider` / `meta.model` as the endpoint returns them (AGT-004, AGT-005). If an endpoint reports no token counts, `input_tokens` and `output_tokens` MAY be estimated and the estimate MUST be flagged `"estimated": true`.
|
|
37
|
-
- **ADP-011** Cost MUST be computed from an explicit `price` in config: `{input_per_mtok, output_per_mtok}` in USD per million tokens. v0.1 ships no built-in price table, because prices change and must never be guessed. Endpoints on the local machine (`localhost`, `127.0.0.1`, `::1`, `0.0.0.0`) default to `cost_usd: 0`; `command` agents and `http` agents report their own usage or cost 0. Any other agent without a price reports `cost_usd: null`, and the runner applies the token cap instead (RUN-019).
|
|
38
|
-
- **ADP-017** `openai_compat` MUST default to plain-text mode (works with every server) and use native tool calls only when config sets `tool_calls: true`; `json_mode: true` MAY request a JSON response format.
|
|
39
|
+
- **ADP-011** Cost MUST be computed from an explicit `price` in config: `{input_per_mtok, output_per_mtok}` in USD per million tokens. v0.1 ships no built-in price table, because prices change and must never be guessed. A cost reported by the provider is used when no `price` is set (ADP-022). Endpoints on the local machine (`localhost`, `127.0.0.1`, `::1`, `0.0.0.0`) default to `cost_usd: 0`; `command` agents and `http` agents report their own usage or cost 0. Any other agent without a price reports `cost_usd: null`, and the runner applies the token cap instead (RUN-019).
|
|
40
|
+
- **ADP-017** `openai_compat` and every preset MUST default to plain-text mode (works with every server) and use native tool calls only when config sets `tool_calls: true`; `json_mode: true` MAY request a JSON response format.
|
|
39
41
|
- **ADP-018** The `anthropic` adapter MUST let the server choose tool use (`tool_choice: auto`), since some models reject forced tool choice, and MUST NOT send sampling parameters unless config sets them. A `refusal` stop reason MUST be reported as an `AgentError` naming the stop details.
|
|
40
42
|
- **ADP-019** The `mcp` adapter MUST start the configured MCP server over stdio, call the configured tool (default `act`) with one argument, `request`, holding the Request, and parse the tool's text result as a Reply. It requires Python 3.10 or newer (the MCP SDK's minimum).
|
|
43
|
+
### Provider presets (ADR-0005)
|
|
44
|
+
- **ADP-020** The framework MUST ship these presets as built-in adapters, each a row in one table over `openai_compat`:
|
|
45
|
+
|
|
46
|
+
| `use` | default `base_url` | default `api_key_env` |
|
|
47
|
+
| --- | --- | --- |
|
|
48
|
+
| `openai` | `https://api.openai.com/v1` | `OPENAI_API_KEY` |
|
|
49
|
+
| `openrouter` | `https://openrouter.ai/api/v1` | `OPENROUTER_API_KEY` |
|
|
50
|
+
| `groq` | `https://api.groq.com/openai/v1` | `GROQ_API_KEY` |
|
|
51
|
+
| `deepseek` | `https://api.deepseek.com/v1` | `DEEPSEEK_API_KEY` |
|
|
52
|
+
| `gemini` | `https://generativelanguage.googleapis.com/v1beta/openai` | `GEMINI_API_KEY` |
|
|
53
|
+
| `mistral` | `https://api.mistral.ai/v1` | `MISTRAL_API_KEY` |
|
|
54
|
+
| `together` | `https://api.together.xyz/v1` | `TOGETHER_API_KEY` |
|
|
55
|
+
| `ollama` | `http://localhost:11434/v1` | none |
|
|
56
|
+
|
|
57
|
+
A preset only fills in missing config: any key, including `base_url` and `api_key_env`, MAY be overridden, and `api_key_env: null` sends no key. `model` stays required. Replies MUST record the preset name as `meta.provider` unless config sets `provider`. A hosted preset MUST NOT count as a local endpoint for cost (ADP-011), even when `base_url` points at the local machine (for example a proxy), unless config sets `local: true`.
|
|
58
|
+
- **ADP-021** A hosted preset MUST check its key when the agent is created: if the variable is not set, it MUST raise a config error naming the variable and the service, before any request is sent. The suggested fix MUST say how to send no key (`api_key_env: null`), since removing `api_key_env` restores the default.
|
|
59
|
+
- **ADP-022** The `openrouter` preset MUST ask the service to report usage (`"usage": {"include": true}`) and, when config sets no `price`, MUST use the cost the response reports (`usage.cost`, USD) as `cost_usd`. A missing, non-numeric, negative or non-finite reported cost MUST be ignored, and ADP-011 applies.
|
|
60
|
+
- **ADP-023** The `openrouter` preset MUST NOT send attribution headers by default; config `app_url` sends `HTTP-Referer` and `app_name` sends `X-Title`.
|
|
61
|
+
- **ADP-024** The `ollama` preset MUST need no key, cost 0 by default (ADP-011), and when the server cannot be reached (connection refused, or host not found) its error MUST name the fix: start Ollama with `ollama serve`. A timeout is reported as a timeout, since a running Ollama can be slow to load a model.
|
|
41
62
|
- **ADP-012** Retries MUST use exponential backoff with jitter and honor `Retry-After`; each attempt MUST be reported (AGT-010). Local connection failures (server not running) MUST give an error with the fix (for example "is the server at http://localhost:11434 running?").
|
|
42
63
|
- **ADP-013** Scripted bots MUST be deterministic from the seed and cost nothing.
|
|
43
64
|
|
|
44
65
|
### Security and testing
|
|
45
66
|
- **ADP-014** API keys MUST be read from the environment only, and MUST NOT be logged or appear in error text (SEC-001, SEC-002).
|
|
46
67
|
- **ADP-015** The `command` adapter runs user-chosen programs; it MUST NOT use a shell by default, MUST pass only the Request on stdin, MUST enforce `timeout_s`, MUST NOT give the program the log or world objects (AGT-008), and MUST start it with the minimal environment of SEC-010.
|
|
47
|
-
- **ADP-016** Every adapter MUST ship recorded fixtures or a local test double, so CI needs no keys, network or model; live tests are opt-in via an environment flag.
|
|
68
|
+
- **ADP-016** Every adapter and preset MUST ship recorded fixtures or a local test double, so CI needs no keys, network or model; live tests are opt-in via an environment flag.
|
|
48
69
|
|
|
49
70
|
## 4. Acceptance criteria
|
|
50
71
|
| Requirement | Test ID | Notes |
|
|
@@ -56,13 +77,16 @@ AgentPlay is **model-neutral**: any AI agent can play, hosted or local, from any
|
|
|
56
77
|
| ADP-008..011 | `ADP-008`..`ADP-011` | recorded OpenAI-compatible and Anthropic responses; no-token-count fallback |
|
|
57
78
|
| ADP-012..013 | `ADP-012`, `ADP-013` | 429 fixture, server-down message |
|
|
58
79
|
| ADP-014..016 | `ADP-014`..`ADP-016` | fake key never leaks; command timeout |
|
|
80
|
+
| ADP-020..024 | `ADP-020`..`ADP-024` | each preset against a local fake server with `base_url` overridden; OpenRouter cost fixture |
|
|
59
81
|
|
|
60
82
|
## 5. Examples
|
|
61
83
|
```yaml
|
|
62
84
|
agents:
|
|
63
85
|
- {id: a, use: scripted/random} # free bot
|
|
64
86
|
- {id: b, use: openai_compat, config: {base_url: "http://localhost:11434/v1", model: llama3}} # local
|
|
65
|
-
- {id: c, use:
|
|
87
|
+
- {id: c, use: openrouter, config: {model: some/model}} # key from OPENROUTER_API_KEY
|
|
88
|
+
- {id: f, use: ollama, config: {model: llama3.2}} # local, free
|
|
89
|
+
- {id: g, use: openai_compat, config: {base_url: "http://localhost:1234/v1", model: local-model}} # any other server
|
|
66
90
|
- {id: d, use: command, config: {command: ["python", "my_agent.py"]}} # any program
|
|
67
91
|
- {id: e, use: anthropic, config: {model: some-model, api_key_env: ANTHROPIC_API_KEY}}
|
|
68
92
|
```
|
|
@@ -79,3 +103,6 @@ agents:
|
|
|
79
103
|
- 2026-11-30: ADP-019 passes the Request as a single `request` argument, since MCP tools declare fixed parameters.
|
|
80
104
|
- 2026-11-30: ADP-015 refers to SEC-010 (minimal environment for agent programs).
|
|
81
105
|
- 2026-11-30: Implemented in v0.1.0; every requirement has a test (PRO-004, PRO-011).
|
|
106
|
+
- 2026-11-30: Provider presets (ADR-0005): ADP-020 to ADP-024 added; ADP-004, ADP-005, ADP-011, ADP-016 and ADP-017 updated for presets.
|
|
107
|
+
- 2026-11-30: Review of the presets: hosted presets are never local for cost unless `local: true` (ADP-020), the missing-key fix names `api_key_env: null` (ADP-021), reported cost is validated (ADP-022), and the Ollama hint covers unknown hosts (ADP-024).
|
|
108
|
+
- 2026-11-30: ADP-020 to ADP-024 implemented in v0.2.0.
|
|
@@ -132,8 +132,14 @@ def post_json(
|
|
|
132
132
|
transport: Transport,
|
|
133
133
|
secrets: Sequence[str] = (),
|
|
134
134
|
server: Optional[str] = None,
|
|
135
|
+
down_hint: Optional[str] = None,
|
|
135
136
|
) -> Tuple[Any, List[Dict[str, Any]]]:
|
|
136
|
-
"""POST JSON and return (parsed JSON, retry history).
|
|
137
|
+
"""POST JSON and return (parsed JSON, retry history).
|
|
138
|
+
|
|
139
|
+
`server` names the base URL in hints; `down_hint` is the fix shown when the server cannot be
|
|
140
|
+
reached (connection refused or host not found), replacing the generic one. Timeouts keep
|
|
141
|
+
their own message.
|
|
142
|
+
"""
|
|
137
143
|
body = json.dumps(payload).encode("utf-8")
|
|
138
144
|
all_headers = {"Content-Type": "application/json", "Accept": "application/json", **headers}
|
|
139
145
|
where = server or url
|
|
@@ -170,11 +176,10 @@ def post_json(
|
|
|
170
176
|
if isinstance(reason, (socket.timeout, TimeoutError)):
|
|
171
177
|
return Failure(True, f"no response from {where} within {timeout:g} s")
|
|
172
178
|
if isinstance(reason, ConnectionRefusedError) or "refused" in str(reason).lower():
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return Failure(True, scrub(f"cannot reach {where}: {reason}", secrets))
|
|
179
|
+
fix = down_hint or f"is the server at {where} running?"
|
|
180
|
+
return Failure(True, f"cannot reach {where}: connection refused; {fix}")
|
|
181
|
+
message = f"cannot reach {where}: {reason}" + (f"; {down_hint}" if down_hint else "")
|
|
182
|
+
return Failure(True, scrub(message, secrets))
|
|
178
183
|
return None
|
|
179
184
|
|
|
180
185
|
return call_with_retries(once, classify, retries=retries, sleep=sleep)
|
|
@@ -26,15 +26,20 @@ def require(config: Dict[str, Any], key: str, adapter: str, example: str = "..."
|
|
|
26
26
|
return value
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
def read_key(env_name: Optional[str]) -> Optional[str]:
|
|
30
|
-
"""Read an API key from the environment variable named in config (SEC-001).
|
|
29
|
+
def read_key(env_name: Optional[str], adapter: Optional[str] = None) -> Optional[str]:
|
|
30
|
+
"""Read an API key from the environment variable named in config (SEC-001).
|
|
31
|
+
|
|
32
|
+
`adapter` names the adapter in the error, for presets whose key variable is a default.
|
|
33
|
+
"""
|
|
31
34
|
if not env_name:
|
|
32
35
|
return None
|
|
33
36
|
value = os.environ.get(env_name)
|
|
34
37
|
if not value:
|
|
38
|
+
needed = f" (the {adapter} adapter reads its API key from it)" if adapter else ""
|
|
39
|
+
no_key = "set api_key_env: null" if adapter else "remove api_key_env"
|
|
35
40
|
raise ConfigError(
|
|
36
|
-
f"environment variable {env_name} is not set",
|
|
37
|
-
f"export {env_name}=<your key>, or
|
|
41
|
+
f"environment variable {env_name} is not set{needed}",
|
|
42
|
+
f"export {env_name}=<your key>, or {no_key} for servers that need no key",
|
|
38
43
|
)
|
|
39
44
|
return value
|
|
40
45
|
|