agentplaykit 0.1.0__tar.gz → 0.1.1__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/.claude/hooks/session-start.sh +12 -0
- agentplaykit-0.1.1/.claude/settings.json +14 -0
- agentplaykit-0.1.1/.github/workflows/release.yml +112 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/CHANGELOG.md +27 -0
- agentplaykit-0.1.1/CLAUDE.md +19 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/PKG-INFO +4 -4
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/README.md +3 -3
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/guides/models.md +25 -2
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/quickstart.md +25 -2
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/release-checklist.md +18 -20
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/mkdocs.yml +1 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/SPEC-002-agent.md +2 -1
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/SPEC-007-cli.md +2 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/SPEC-010-evaluators.md +2 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/__init__.py +1 -1
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/agents/_http.py +1 -1
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/agents/anthropic_agent.py +2 -2
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/agents/http_agent.py +2 -2
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/agents/openai_compat.py +2 -2
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/cli/main.py +18 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/evals/summary.py +28 -12
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_adapters.py +14 -1
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_cli.py +21 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_evaluators.py +32 -0
- agentplaykit-0.1.0/.github/workflows/release.yml +0 -80
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/.github/CODEOWNERS +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/.github/ISSUE_TEMPLATE/bug.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/.github/ISSUE_TEMPLATE/spec-proposal.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/.github/ISSUE_TEMPLATE/world-request.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/.github/workflows/ci.yml +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/.github/workflows/docs.yml +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/.gitignore +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/.pre-commit-config.yaml +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/CODE_OF_CONDUCT.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/CONTRIBUTING.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/GOVERNANCE.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/LICENSE +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/MAINTAINERS.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/SECURITY.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/adr/0000-template.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/adr/0001-name-and-package-name.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/adr/0002-tooling-and-defaults.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/adr/0003-model-neutral.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/adr/0004-no-built-in-prices.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/development-plan.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/guides/cli.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/guides/run-log.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/guides/scenarios.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/index.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/security-review.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/tutorials/evaluate.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/tutorials/write-a-world.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/docs/tutorials/write-an-agent.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/examples/command-agent/my_agent.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/examples/command-agent/scenario.yaml +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/examples/guess/bisect_agent.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/examples/guess/guess_world.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/examples/guess/scenario.yaml +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/examples/ox-chat/scenario.yaml +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/examples/ox-llm/scenario.yaml +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/examples/ox_demo.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/examples/treasure/scenario.yaml +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/examples/treasure/treasure_checker.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/examples/treasure/treasure_world.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/pyproject.toml +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/scripts/check_boundaries.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/scripts/check_licenses.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/scripts/check_spdx.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/scripts/check_spec_links.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/scripts/mkdocs_hooks.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/SPEC-000-process.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/SPEC-001-environment.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/SPEC-003-run-log.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/SPEC-004-runner.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/SPEC-005-scenario.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/SPEC-006-registry.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/SPEC-008-message-bus.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/SPEC-009-adapters.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/SPEC-011-security.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/TEMPLATE.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/schemas/evalresult.schema.json +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/schemas/runlog.schema.json +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/schemas/scenario.schema.json +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/specs/untested.yaml +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/__main__.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/agents/__init__.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/agents/command.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/agents/config.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/agents/mcp_agent.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/agents/pricing.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/agents/proc.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/agents/prompting.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/agents/scripted.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/cli/__init__.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/core/__init__.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/core/agent.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/core/bus.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/core/environment.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/core/evaluator.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/core/log.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/core/plain.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/core/runner.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/envs/__init__.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/envs/blank.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/envs/ox.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/envs/rps.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/evals/__init__.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/evals/judge.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/evals/outcome.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/py.typed +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/registry/__init__.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/scenario/__init__.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/scenarios/demo.yaml +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/schemas/evalresult.schema.json +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/schemas/runlog.schema.json +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/schemas/scenario.schema.json +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/src/agentplaykit/testkit.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/__init__.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/__init__.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/conftest.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/fakes.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/helpers.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/plugin_pkg.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_agent.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_environment.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_message_bus.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_registry.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_run_log.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_runner.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_scenario.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_schemas.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_security.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_specs.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/conformance/test_testkit.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/fixtures/providers/README.md +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/fixtures/providers/anthropic_refusal.json +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/fixtures/providers/anthropic_text.json +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/fixtures/providers/anthropic_tool_use.json +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/fixtures/providers/openai_chat_no_usage.json +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/fixtures/providers/openai_chat_text.json +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/fixtures/providers/openai_chat_tool.json +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/fixtures/sample_run.jsonl +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/fixtures/sample_scenario.yaml +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/golden/ox_minimax_vs_random_seed7.jsonl +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/live/__init__.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/live/test_live_adapters.py +0 -0
- {agentplaykit-0.1.0 → agentplaykit-0.1.1}/tests/test_smoke.py +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Installs dev dependencies in Claude Code on the web sessions only.
|
|
3
|
+
# Locally, use the .venv described in CONTRIBUTING.md.
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
|
|
6
|
+
if [ "${CLAUDE_CODE_REMOTE:-}" != "true" ]; then
|
|
7
|
+
exit 0
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
cd "${CLAUDE_PROJECT_DIR:-.}"
|
|
11
|
+
python -m pip install -q -e ".[dev]"
|
|
12
|
+
pre-commit install || true
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
# Publishes a version to PyPI and creates its GitHub release. Ways to start it:
|
|
3
|
+
# - Automatic: merge a change of __version__ into master. If that version has no release yet,
|
|
4
|
+
# it is released; any other push to master does nothing.
|
|
5
|
+
# - Push a tag such as v0.1.0, or create a release with a new v* tag on GitHub.
|
|
6
|
+
# - Actions -> Release -> Run workflow, from master or from a v* tag.
|
|
7
|
+
# Publishing uses PyPI trusted publishing: no API token is stored in this repository
|
|
8
|
+
# (see docs/release-checklist.md). Every step is safe to re-run for the same version.
|
|
9
|
+
on:
|
|
10
|
+
push:
|
|
11
|
+
branches: [master]
|
|
12
|
+
tags: ["v*"]
|
|
13
|
+
workflow_dispatch:
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
concurrency:
|
|
19
|
+
group: release-${{ github.ref }}
|
|
20
|
+
cancel-in-progress: false
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
decide:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
outputs:
|
|
26
|
+
release: ${{ steps.decide.outputs.release }}
|
|
27
|
+
tag: ${{ steps.decide.outputs.tag }}
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
- id: decide
|
|
31
|
+
name: Is there a version to release?
|
|
32
|
+
env: { GH_TOKEN: "${{ github.token }}" }
|
|
33
|
+
run: |
|
|
34
|
+
version=$(sed -n 's/^__version__ = "\(.*\)"$/\1/p' src/agentplaykit/__init__.py)
|
|
35
|
+
tag="v$version"
|
|
36
|
+
echo "package version: $version"
|
|
37
|
+
case "$GITHUB_REF" in
|
|
38
|
+
refs/tags/v*)
|
|
39
|
+
if [ "$GITHUB_REF_NAME" != "$tag" ]; then
|
|
40
|
+
echo "tag $GITHUB_REF_NAME does not match the package version $version"; exit 1
|
|
41
|
+
fi
|
|
42
|
+
release=true ;;
|
|
43
|
+
refs/heads/master)
|
|
44
|
+
if git ls-remote --exit-code --tags origin "refs/tags/$tag" > /dev/null; then
|
|
45
|
+
echo "$tag is already released; nothing to do"
|
|
46
|
+
release=false
|
|
47
|
+
else
|
|
48
|
+
echo "$tag has no release yet; releasing it"
|
|
49
|
+
release=true
|
|
50
|
+
fi ;;
|
|
51
|
+
*)
|
|
52
|
+
echo "run this from master or a v* tag, not $GITHUB_REF"; exit 1 ;;
|
|
53
|
+
esac
|
|
54
|
+
echo "release=$release" >> "$GITHUB_OUTPUT"
|
|
55
|
+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
|
56
|
+
|
|
57
|
+
build:
|
|
58
|
+
needs: decide
|
|
59
|
+
if: needs.decide.outputs.release == 'true'
|
|
60
|
+
runs-on: ubuntu-latest
|
|
61
|
+
steps:
|
|
62
|
+
- uses: actions/checkout@v4
|
|
63
|
+
- uses: actions/setup-python@v5
|
|
64
|
+
with: { python-version: "3.12" }
|
|
65
|
+
- run: python -m pip install -e ".[dev]" build twine
|
|
66
|
+
- run: python -m pytest -q
|
|
67
|
+
- run: python -m build
|
|
68
|
+
- run: python -m twine check dist/*
|
|
69
|
+
- uses: actions/upload-artifact@v4
|
|
70
|
+
with: { name: dist, path: dist/ }
|
|
71
|
+
|
|
72
|
+
publish:
|
|
73
|
+
needs: [decide, build]
|
|
74
|
+
runs-on: ubuntu-latest
|
|
75
|
+
# The pypi environment must allow the tag pattern v* and the branch master.
|
|
76
|
+
environment: {name: pypi, url: "https://pypi.org/project/agentplaykit/"}
|
|
77
|
+
permissions:
|
|
78
|
+
id-token: write
|
|
79
|
+
steps:
|
|
80
|
+
- uses: actions/download-artifact@v4
|
|
81
|
+
with: { name: dist, path: dist/ }
|
|
82
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
83
|
+
with:
|
|
84
|
+
skip-existing: true # a re-run for the same version must not fail
|
|
85
|
+
|
|
86
|
+
github-release:
|
|
87
|
+
needs: [decide, publish]
|
|
88
|
+
runs-on: ubuntu-latest
|
|
89
|
+
permissions:
|
|
90
|
+
contents: write
|
|
91
|
+
env:
|
|
92
|
+
TAG: ${{ needs.decide.outputs.tag }}
|
|
93
|
+
GH_TOKEN: ${{ github.token }}
|
|
94
|
+
steps:
|
|
95
|
+
- uses: actions/checkout@v4
|
|
96
|
+
- uses: actions/download-artifact@v4
|
|
97
|
+
with: { name: dist, path: dist/ }
|
|
98
|
+
- name: Release notes from CHANGELOG.md
|
|
99
|
+
run: |
|
|
100
|
+
version="${TAG#v}"
|
|
101
|
+
awk -v v="$version" '/^## \[/{p = index($0, "[" v "]") > 0; next} p' CHANGELOG.md > notes.md
|
|
102
|
+
test -s notes.md || { echo "no CHANGELOG section for $version"; exit 1; }
|
|
103
|
+
- name: Create the tag and release, or update a release made in the browser
|
|
104
|
+
run: |
|
|
105
|
+
title="AgentPlay $TAG"
|
|
106
|
+
if gh release view "$TAG" > /dev/null 2>&1; then
|
|
107
|
+
gh release edit "$TAG" --title "$title" --notes-file notes.md
|
|
108
|
+
gh release upload "$TAG" dist/* --clobber
|
|
109
|
+
else
|
|
110
|
+
# Creates the tag at the released commit when it does not exist yet.
|
|
111
|
+
gh release create "$TAG" dist/* --target "$GITHUB_SHA" --title "$title" --notes-file notes.md
|
|
112
|
+
fi
|
|
@@ -6,6 +6,33 @@ Format: [Keep a Changelog](https://keepachangelog.com/). Versioning: [SemVer](ht
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.1.1] - 2026-11-30
|
|
10
|
+
|
|
11
|
+
Fixes from trying v0.1.0 with free hosted models and on Windows.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Model adapters retry rate limits and server errors 5 times by default (was 2), waiting 1, 2,
|
|
15
|
+
4, 8 and 16 seconds (or as long as the server's `Retry-After` asks). Free models on
|
|
16
|
+
OpenRouter often answer `429`; two quick retries aborted most runs. Set `retries` to change it.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- `play --runs N` now shows why runs failed: summary rows carry the run's `error`, the summary
|
|
20
|
+
file has an `errors` table, and the printed summary lists each error with its count
|
|
21
|
+
(EVL-015). Before, a failing provider showed only as "aborted".
|
|
22
|
+
- Piping output into a program that stops reading early (`| head`) no longer prints a Python
|
|
23
|
+
traceback; the command exits quietly with code 1 (CLI-012).
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
- Automatic releases: merging a new `__version__` into `master` publishes it to PyPI and creates
|
|
27
|
+
the tag and GitHub release; merges that keep the version do nothing. Tags, the browser and
|
|
28
|
+
"Run workflow" still work as manual routes (see `docs/release-checklist.md`).
|
|
29
|
+
|
|
30
|
+
### Docs
|
|
31
|
+
- Quickstart: installing in a virtual environment on Windows and macOS/Linux, and what to do
|
|
32
|
+
when `agentplaykit` is "not recognized as a command" (`python -m agentplaykit`).
|
|
33
|
+
- Real AI models: an OpenRouter section (chat vs embedding models, free-model rate limits).
|
|
34
|
+
- README now installs from PyPI.
|
|
35
|
+
|
|
9
36
|
## [0.1.0] - 2026-11-30
|
|
10
37
|
|
|
11
38
|
First release: the engine for putting AI agents into worlds, letting them act and talk, and
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# AgentPlay
|
|
2
|
+
|
|
3
|
+
Spec-driven Python framework (package `agentplaykit`). See [CONTRIBUTING.md](CONTRIBUTING.md) for rules; the spec in `specs/` is the source of truth.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
- Local: `python -m venv .venv`, activate it (`.venv\Scripts\activate` on Windows), then `pip install -e ".[dev]"` and `pre-commit install`.
|
|
7
|
+
- Claude Code on the web: dependencies are installed automatically by `.claude/hooks/session-start.sh`.
|
|
8
|
+
|
|
9
|
+
## Checks (same as CI)
|
|
10
|
+
```bash
|
|
11
|
+
python scripts/check_spdx.py && python scripts/check_boundaries.py
|
|
12
|
+
ruff check . && ruff format --check . && mypy && pytest
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Conventions
|
|
16
|
+
- Development branch: `claude/laughing-clarke-wakxes`.
|
|
17
|
+
- Python 3.8-compatible runtime code; every Python file starts with `# SPDX-License-Identifier: MIT`.
|
|
18
|
+
- `core` must not import `agents`, `envs` or `evals`.
|
|
19
|
+
- Sign off commits (`git commit -s`).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: agentplaykit
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
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/
|
|
@@ -42,18 +42,18 @@ Description-Content-Type: text/markdown
|
|
|
42
42
|
|
|
43
43
|
An MIT-licensed Python framework for putting AI agents into worlds, letting them act and talk, and scoring and logging what happens.
|
|
44
44
|
|
|
45
|
-
**Status:**
|
|
45
|
+
**Status:** released on PyPI as [`agentplaykit`](https://pypi.org/project/agentplaykit/). Docs: <https://agentplay.itejas.dev>. The specs in [`specs/`](specs/) are the source of truth; every requirement has a test.
|
|
46
46
|
|
|
47
47
|
## Install
|
|
48
48
|
Python 3.8 or newer. Plain `pip` works:
|
|
49
49
|
```bash
|
|
50
|
-
pip install agentplaykit
|
|
50
|
+
pip install agentplaykit
|
|
51
51
|
pip install -e ".[dev]" # from a clone, for development
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
## Try it
|
|
55
55
|
```bash
|
|
56
|
-
pip install
|
|
56
|
+
pip install agentplaykit
|
|
57
57
|
agentplaykit play # built-in demo, no API key needed
|
|
58
58
|
agentplaykit play examples/guess/scenario.yaml # a custom world + agent from plain .py files
|
|
59
59
|
agentplaykit play examples/ox-chat/scenario.yaml # two agents play OX and chat between moves
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
An MIT-licensed Python framework for putting AI agents into worlds, letting them act and talk, and scoring and logging what happens.
|
|
4
4
|
|
|
5
|
-
**Status:**
|
|
5
|
+
**Status:** released on PyPI as [`agentplaykit`](https://pypi.org/project/agentplaykit/). Docs: <https://agentplay.itejas.dev>. The specs in [`specs/`](specs/) are the source of truth; every requirement has a test.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
Python 3.8 or newer. Plain `pip` works:
|
|
9
9
|
```bash
|
|
10
|
-
pip install agentplaykit
|
|
10
|
+
pip install agentplaykit
|
|
11
11
|
pip install -e ".[dev]" # from a clone, for development
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
## Try it
|
|
15
15
|
```bash
|
|
16
|
-
pip install
|
|
16
|
+
pip install agentplaykit
|
|
17
17
|
agentplaykit play # built-in demo, no API key needed
|
|
18
18
|
agentplaykit play examples/guess/scenario.yaml # a custom world + agent from plain .py files
|
|
19
19
|
agentplaykit play examples/ox-chat/scenario.yaml # two agents play OX and chat between moves
|
|
@@ -26,9 +26,31 @@ into the core, and every model gets the same prompt.
|
|
|
26
26
|
temperature: 0.2 # sent only if set
|
|
27
27
|
max_output_tokens: 1024
|
|
28
28
|
timeout_s: 120
|
|
29
|
-
retries:
|
|
29
|
+
retries: 5 # default; about 30 s of backoff for rate limits
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
## OpenRouter
|
|
33
|
+
|
|
34
|
+
OpenRouter gives one key for hundreds of hosted models and speaks the OpenAI format:
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
- id: x
|
|
38
|
+
use: openai_compat
|
|
39
|
+
config:
|
|
40
|
+
base_url: "https://openrouter.ai/api/v1"
|
|
41
|
+
model: "<provider>/<model>" # copy the exact id from openrouter.ai/models
|
|
42
|
+
api_key_env: OPENROUTER_API_KEY
|
|
43
|
+
price: {input_per_mtok: 0.0, output_per_mtok: 0.0} # the model's listed prices
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- Pick a **chat (text to text)** model. Embedding models (often with `embed` in the name)
|
|
47
|
+
cannot play: every request is refused and runs end as `aborted`.
|
|
48
|
+
- Models ending in `:free` cost nothing but have tight rate limits. Many games in a row hit
|
|
49
|
+
`429` errors; the multi-run summary lists them under `errors:`. Run fewer games, wait
|
|
50
|
+
between batches, or raise `retries`.
|
|
51
|
+
- `usage` events record the model OpenRouter actually served, so you can see if it routed you
|
|
52
|
+
elsewhere.
|
|
53
|
+
|
|
32
54
|
## `anthropic`
|
|
33
55
|
|
|
34
56
|
```yaml
|
|
@@ -64,6 +86,7 @@ parameters unless you set them, and reports a refusal as an agent error.
|
|
|
64
86
|
|
|
65
87
|
## Retries
|
|
66
88
|
|
|
67
|
-
Rate limits and server errors are retried with backoff (`retries`, default 2
|
|
89
|
+
Rate limits and server errors are retried with backoff (`retries`, default 5: waits of 1, 2, 4, 8
|
|
90
|
+
and 16 seconds), honoring
|
|
68
91
|
`Retry-After`. Each retry is logged as a `provider_error`. If the provider stays down, the
|
|
69
92
|
run ends as `aborted`; this never counts as a forfeit.
|
|
@@ -8,8 +8,31 @@ Python 3.8 or newer. Plain `pip` works:
|
|
|
8
8
|
pip install agentplaykit
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
We recommend a virtual environment, so AgentPlay and its dependencies stay separate:
|
|
12
|
+
|
|
13
|
+
=== "Windows"
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
python -m venv .venv
|
|
17
|
+
.venv\Scripts\activate
|
|
18
|
+
pip install agentplaykit
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
=== "macOS / Linux"
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
python3 -m venv .venv
|
|
25
|
+
source .venv/bin/activate
|
|
26
|
+
pip install agentplaykit
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
!!! tip "'agentplaykit' is not recognized as a command"
|
|
30
|
+
The folder pip put the command in is not on your PATH, usually because the virtual
|
|
31
|
+
environment is not active (your prompt should start with `(.venv)`). Either activate it,
|
|
32
|
+
or run every command through Python instead: `python -m agentplaykit play`.
|
|
33
|
+
|
|
34
|
+
In PowerShell, if activation says *running scripts is disabled*, run
|
|
35
|
+
`Set-ExecutionPolicy -Scope CurrentUser RemoteSigned` once, then activate again.
|
|
13
36
|
|
|
14
37
|
## 2. Run the demo
|
|
15
38
|
|
|
@@ -19,38 +19,36 @@ a test or a written reason (`scripts/check_spec_links.py`).
|
|
|
19
19
|
- [x] GitHub, Settings, Pages: set the source to **GitHub Actions** (the `Docs` workflow then publishes the site).
|
|
20
20
|
- [x] Make `master` the default branch and allow it to deploy to the `github-pages` environment.
|
|
21
21
|
- [ ] Custom domain `agentplay.itejas.dev`: DNS `CNAME` record to `thetejasmagade.github.io`, then Settings, Pages, Custom domain, and **Enforce HTTPS** once the certificate is issued.
|
|
22
|
-
- [
|
|
23
|
-
- [
|
|
22
|
+
- [x] PyPI: add a **trusted publisher** for project `agentplaykit`: owner `thetejasmagade`, repository `agentplay`, workflow `release.yml`, environment `pypi`. No token is stored in the repository.
|
|
23
|
+
- [x] GitHub, Settings, Environments: create `pypi`, allow tags matching `v*` to deploy, and optionally require a reviewer before publishing.
|
|
24
|
+
- [ ] Also allow the branch `master` in the `pypi` environment (automatic releases, since v0.1.1).
|
|
24
25
|
- [ ] Name checks still open from ADR-0001: domain and trademark search for "AgentPlay" / "agentplaykit".
|
|
25
26
|
- [x] Add a contact address for the Code of Conduct in `MAINTAINERS.md`.
|
|
26
27
|
- [ ] Optional: branch protection on `master` (one approval, required checks) to enforce SPEC-000 PRO-006.
|
|
27
28
|
- [x] Set the date of the `0.1.0` section in `CHANGELOG.md`.
|
|
28
29
|
|
|
29
|
-
##
|
|
30
|
+
## Releasing a version
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
**Automatic (normal route).** In a pull request, set the new `__version__` in
|
|
33
|
+
`src/agentplaykit/__init__.py` and add its section to `CHANGELOG.md`. When that PR is merged
|
|
34
|
+
into `master`, the `Release` workflow sees a version with no release yet and releases it: tests,
|
|
35
|
+
build and checks, PyPI, then the tag and the GitHub release with the changelog notes. Merges that
|
|
36
|
+
do not change the version do nothing.
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
One-time setup: Settings, Environments, `pypi`, deployment branches and tags must allow the
|
|
39
|
+
**branch `master`** as well as the **tag pattern `v*`**. Tick **Required reviewers** there if
|
|
40
|
+
every release should wait for a confirmation on its run page.
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
git checkout master && git pull
|
|
39
|
-
git tag -a v0.1.0 -m "AgentPlay v0.1.0"
|
|
40
|
-
git push origin v0.1.0
|
|
41
|
-
```
|
|
42
|
+
**By hand (backup).** Any of these releases the version that is in the code; it must match the tag.
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
- Terminal: `git tag -a v0.1.1 -m "AgentPlay v0.1.1"` then `git push origin v0.1.1`.
|
|
45
|
+
- Browser or GitHub app: Releases, Draft a new release, new tag `v0.1.1` on `master`, empty notes, Publish.
|
|
46
|
+
- Actions, Release, Run workflow, from `master` or from the tag.
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
2. **Choose a tag**: type `v0.1.0` and pick **Create new tag: v0.1.0 on publish**; target `master`.
|
|
47
|
-
3. Title `AgentPlay v0.1.0`; leave the notes empty (the workflow fills them from the changelog).
|
|
48
|
-
4. **Publish release**. Creating the tag starts the workflow; it attaches the built files when it finishes.
|
|
49
|
-
5. If no `Release` run appears under **Actions** within a minute: **Actions**, **Release**,
|
|
50
|
-
**Run workflow**, set **Use workflow from** to the tag `v0.1.0`, and run it.
|
|
48
|
+
Every step is safe to re-run for the same version.
|
|
51
49
|
|
|
52
50
|
## After release
|
|
53
51
|
|
|
54
52
|
- [ ] `pip install agentplaykit && agentplaykit play` on a clean machine.
|
|
55
|
-
- [
|
|
53
|
+
- [x] Update the README install line (drop the "from a clone" note).
|
|
56
54
|
- [ ] Open the `v0.2` milestone (viewer) from the roadmap.
|
|
@@ -23,7 +23,7 @@ Define the one interface an agent (scripted bot, model adapter, human proxy) imp
|
|
|
23
23
|
- **AGT-007** An agent MAY provide `reset(seed: int, agent_id: str) -> None`, called once per episode before the first `act`. Any randomness in a scripted agent MUST derive from that seed.
|
|
24
24
|
- **AGT-008** An agent MUST NOT receive or touch world internals, the checker, other agents' observations, or the log. It sees only the Request.
|
|
25
25
|
- **AGT-009** If an agent cannot produce a Reply it MUST raise `AgentError` (model failure, unparseable output) or `ProviderError` (network, rate limit, 5xx). The runner treats these differently (SPEC-004).
|
|
26
|
-
- **AGT-010** An agent SHOULD retry provider errors with backoff inside the adapter, up to a configured count (default
|
|
26
|
+
- **AGT-010** An agent SHOULD retry provider errors with backoff inside the adapter, up to a configured count (default 5, about 30 seconds of backoff in total), before raising `ProviderError`. Each retry MUST be reported to the runner for logging.
|
|
27
27
|
- **AGT-013** An agent MAY provide `close() -> None`; the runner MUST call it once after the episode ends, whatever the reason (to stop a subprocess or close a connection).
|
|
28
28
|
- **AGT-014** An agent MAY provide `secrets() -> list[str]`: values (such as its API key) the runner MUST redact from the log (SEC-002).
|
|
29
29
|
- **AGT-015** Retries that happened before a successful reply MUST be reported in `meta.retries`, a list of `{attempt, message}` objects (how AGT-010 reports them).
|
|
@@ -59,3 +59,4 @@ class Random(Agent): # a scripted agent
|
|
|
59
59
|
- 2026-11-30: Added AGT-012 (`notes` in the Request).
|
|
60
60
|
- 2026-11-30: Added AGT-013 (`close`), AGT-014 (`secrets`), AGT-015 (`meta.retries`); found while implementing M4.
|
|
61
61
|
- 2026-11-30: Implemented in v0.1.0; every requirement has a test (PRO-004, PRO-011).
|
|
62
|
+
- 2026-11-30: AGT-010 default retries 2 -> 5: free hosted models rate-limit often, and two quick retries aborted most runs (v0.1.1).
|
|
@@ -21,6 +21,7 @@ Commands users run: `play`, `check`, `env list`, `doctor` (and `--runs N` in M5)
|
|
|
21
21
|
- **CLI-008** Flags MUST override scenario values and the log MUST record the effective values.
|
|
22
22
|
- **CLI-009** `agentplaykit test <plugin.py> [--world NAME] [--seeds N]` SHOULD check every public `Environment` and `Agent` subclass in the file without changing it: worlds against the SPEC-001 rules, determinism under seeds and log validity; agents for reply shape, capabilities and determinism while playing `--world` (default `blank`). It prints one line per check, `ok` or `FAIL`, with the requirement ID, and exits 0 only if every check passes.
|
|
23
23
|
- **CLI-011** With `--runs N` (N > 1), `--out` MUST name a directory for the logs and summary (default `runs/`), and `play` MUST print the summary table (EVL-007, EVL-014).
|
|
24
|
+
- **CLI-012** When its output is piped into a program that stops reading early (for example `head`), a command MUST exit with code 1 and no traceback.
|
|
24
25
|
- **CLI-010** Output MUST work without color or TTY; color is optional.
|
|
25
26
|
|
|
26
27
|
## 4. Acceptance criteria
|
|
@@ -41,3 +42,4 @@ error: unknown world "oxx" (scenario.yaml:world.use) -> did you mean "ox"? run `
|
|
|
41
42
|
- 2026-11-30: Clarified that forfeits and limit stops exit 0, since the run completed.
|
|
42
43
|
- 2026-11-30: CLI-009 detailed (`--world`, `--seeds`, output); added CLI-011 (`--runs` output).
|
|
43
44
|
- 2026-11-30: Implemented in v0.1.0; every requirement has a test (PRO-004, PRO-011).
|
|
45
|
+
- 2026-11-30: Added CLI-012 (closed output pipe), from v0.1.0 testing.
|
|
@@ -24,6 +24,7 @@ Score what happened using code outside the agent, and summarize many runs. Evalu
|
|
|
24
24
|
- **EVL-011** The interface MUST live in `core` as the base class `Evaluator` (with `name`, `config` and `evaluate(log)`), where `log` is a read-only copy of the parsed run log: `log.events` (list of event objects) and `log.complete`. Implementations live in `evals/` or in plugins.
|
|
25
25
|
- **EVL-012** Results MUST be written by `core` to `<log>.eval.json` (the log path with `.jsonl` replaced) and MUST validate against `specs/schemas/evalresult.schema.json`. A result MAY carry `error` (why the evaluator failed) and `usage` (a judge's tokens and cost).
|
|
26
26
|
- **EVL-013** The built-in `judge` evaluator MUST take `agent: {use, config}` (any agent adapter, SPEC-009) and a `rubric`. It sends that agent one Request whose `observation` holds the rubric and a transcript of the log and whose `actions` is a JSON Schema for `{passed, score, reason}`. Judge usage MUST go in the result's `usage` and MUST NOT count toward the run's cost or limits.
|
|
27
|
+
- **EVL-015** A summary row MUST carry the run's `error` when it ended `world_error` or `aborted`; the summary MUST list each distinct error with how many runs it ended (`errors`), and the printed summary MUST show them, so a failing provider is visible without opening logs.
|
|
27
28
|
- **EVL-014** With `--runs N`, run `i` (from 0) MUST use seed `base + i`; logs are named `<name>-<seed>.jsonl`; a summary `<name>-summary.json` goes next to them. The summary MUST NOT contain timestamps or durations, so the same inputs give an identical file. "Spread" means the population standard deviation, minimum and maximum.
|
|
28
29
|
|
|
29
30
|
## 4. Acceptance criteria
|
|
@@ -42,3 +43,4 @@ Score what happened using code outside the agent, and summarize many runs. Evalu
|
|
|
42
43
|
- 2026-11-30: Accepted by the lead maintainer.
|
|
43
44
|
- 2026-11-30: Resolved the result-file question (`<log>.eval.json`); added EVL-011 to EVL-014; found while implementing M5.
|
|
44
45
|
- 2026-11-30: Implemented in v0.1.0; every requirement has a test (PRO-004, PRO-011).
|
|
46
|
+
- 2026-11-30: Added EVL-015 (errors in multi-run summaries), from user feedback on v0.1.0.
|
|
@@ -73,7 +73,7 @@ def call_with_retries(
|
|
|
73
73
|
history.append({"attempt": attempt, "message": failure.message})
|
|
74
74
|
delay = failure.retry_after
|
|
75
75
|
if delay is None:
|
|
76
|
-
delay = 0
|
|
76
|
+
delay = 2.0 ** (attempt - 1) + random.uniform(0, 0.5) # 1, 2, 4, 8, 16 s
|
|
77
77
|
sleep(min(delay, 60.0))
|
|
78
78
|
|
|
79
79
|
|
|
@@ -9,7 +9,7 @@ Install with: pip install "agentplaykit[anthropic]". Config:
|
|
|
9
9
|
tool_calls default true (tool_choice auto; text is parsed as a fallback)
|
|
10
10
|
max_output_tokens default 16000
|
|
11
11
|
temperature, top_p sent only when set (some models reject them)
|
|
12
|
-
timeout_s, retries defaults 600 and
|
|
12
|
+
timeout_s, retries defaults 600 and 5
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
@@ -115,7 +115,7 @@ class AnthropicAgent(Agent):
|
|
|
115
115
|
response, retries = call_with_retries(
|
|
116
116
|
lambda: self.client.messages.create(**kwargs),
|
|
117
117
|
self._classify,
|
|
118
|
-
retries=int(c.get("retries",
|
|
118
|
+
retries=int(c.get("retries", 5)),
|
|
119
119
|
sleep=self.sleep,
|
|
120
120
|
)
|
|
121
121
|
if getattr(response, "stop_reason", None) == "refusal":
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
|
2
2
|
"""Any agent behind a URL (ADP-004): POSTs the Request as JSON, reads the Reply as JSON.
|
|
3
3
|
|
|
4
|
-
Config: url (required), api_key_env (sent as a Bearer token), timeout_s (60), retries (
|
|
4
|
+
Config: url (required), api_key_env (sent as a Bearer token), timeout_s (60), retries (5).
|
|
5
5
|
The reply may include its own `usage`; without it the call costs 0.
|
|
6
6
|
"""
|
|
7
7
|
|
|
@@ -41,7 +41,7 @@ class HttpAgent(Agent):
|
|
|
41
41
|
request,
|
|
42
42
|
headers={"Authorization": f"Bearer {self.key}"} if self.key else {},
|
|
43
43
|
timeout=float(self.config.get("timeout_s", 60)),
|
|
44
|
-
retries=int(self.config.get("retries",
|
|
44
|
+
retries=int(self.config.get("retries", 5)),
|
|
45
45
|
sleep=self.sleep,
|
|
46
46
|
transport=self.transport,
|
|
47
47
|
secrets=self.secrets(),
|
|
@@ -13,7 +13,7 @@ llama.cpp. Standard library only. Config:
|
|
|
13
13
|
json_mode true to request a JSON response format
|
|
14
14
|
temperature sent only when set
|
|
15
15
|
max_output_tokens default 1024
|
|
16
|
-
timeout_s, retries defaults 120 and
|
|
16
|
+
timeout_s, retries defaults 120 and 5 (about 30 s of backoff for rate limits)
|
|
17
17
|
allow_insecure_http allow sending the key over plain http to a remote host (SEC-009)
|
|
18
18
|
provider name to record in the log (default: the URL's host)
|
|
19
19
|
"""
|
|
@@ -103,7 +103,7 @@ class OpenAICompatAgent(Agent):
|
|
|
103
103
|
payload,
|
|
104
104
|
headers=headers,
|
|
105
105
|
timeout=float(c.get("timeout_s", 120)),
|
|
106
|
-
retries=int(c.get("retries",
|
|
106
|
+
retries=int(c.get("retries", 5)),
|
|
107
107
|
sleep=self.sleep,
|
|
108
108
|
transport=self.transport,
|
|
109
109
|
secrets=self.secrets(),
|
|
@@ -243,7 +243,25 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
243
243
|
return parser
|
|
244
244
|
|
|
245
245
|
|
|
246
|
+
def _silence_stdout() -> None:
|
|
247
|
+
"""After a closed pipe, point stdout at devnull so Python's final flush stays quiet."""
|
|
248
|
+
try:
|
|
249
|
+
devnull = os.open(os.devnull, os.O_WRONLY)
|
|
250
|
+
os.dup2(devnull, sys.stdout.fileno())
|
|
251
|
+
except (OSError, ValueError, AttributeError):
|
|
252
|
+
pass
|
|
253
|
+
|
|
254
|
+
|
|
246
255
|
def main(argv: Optional[List[str]] = None) -> int:
|
|
256
|
+
"""Entry point. A closed output pipe (`| head`) ends quietly with code 1 (CLI-012)."""
|
|
257
|
+
try:
|
|
258
|
+
return _main(argv)
|
|
259
|
+
except BrokenPipeError:
|
|
260
|
+
_silence_stdout()
|
|
261
|
+
return EXIT_RUN
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def _main(argv: Optional[List[str]] = None) -> int:
|
|
247
265
|
from agentplaykit.registry import RegistryError
|
|
248
266
|
from agentplaykit.scenario import ScenarioError
|
|
249
267
|
|
|
@@ -8,7 +8,7 @@ import json
|
|
|
8
8
|
import statistics
|
|
9
9
|
from collections import Counter
|
|
10
10
|
from pathlib import Path
|
|
11
|
-
from typing import Any, Dict, List, Optional, Sequence, Union
|
|
11
|
+
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
|
|
12
12
|
|
|
13
13
|
from agentplaykit.registry import Registry
|
|
14
14
|
from agentplaykit.scenario import Scenario, run_scenario
|
|
@@ -32,6 +32,19 @@ def _outcome_key(winners: Optional[List[str]]) -> str:
|
|
|
32
32
|
return "+".join(winners) if winners else "draw"
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
def _most_runs_first(item: Tuple[str, int]) -> Tuple[int, str]:
|
|
36
|
+
return -item[1], item[0]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _count_errors(rows: List[Dict[str, Any]]) -> Dict[str, int]:
|
|
40
|
+
"""Each distinct error and how many runs it ended, most common first (EVL-015)."""
|
|
41
|
+
counts: Dict[str, int] = {}
|
|
42
|
+
for row in rows:
|
|
43
|
+
if "error" in row:
|
|
44
|
+
counts[str(row["error"])] = counts.get(str(row["error"]), 0) + 1
|
|
45
|
+
return dict(sorted(counts.items(), key=_most_runs_first))
|
|
46
|
+
|
|
47
|
+
|
|
35
48
|
def run_many(
|
|
36
49
|
scenario: Scenario,
|
|
37
50
|
runs: int,
|
|
@@ -59,17 +72,18 @@ def run_many(
|
|
|
59
72
|
while key in evals:
|
|
60
73
|
key, n = f"{res['name']}#{n}", n + 1
|
|
61
74
|
evals[key] = {k: res[k] for k in ("passed", "score", "error") if k in res}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
row: Dict[str, Any] = {
|
|
76
|
+
"seed": seed,
|
|
77
|
+
"log": str(r.log_path),
|
|
78
|
+
"reason": r.reason,
|
|
79
|
+
"steps": r.steps,
|
|
80
|
+
"cost_usd": round(r.total_cost_usd, 10),
|
|
81
|
+
"winners": (r.outcome or {}).get("winners") if r.outcome is not None else None,
|
|
82
|
+
"evals": evals,
|
|
83
|
+
}
|
|
84
|
+
if r.reason in ("world_error", "aborted") and r.error:
|
|
85
|
+
row["error"] = r.error # EVL-015: already redacted by the runner
|
|
86
|
+
rows.append(row)
|
|
73
87
|
|
|
74
88
|
eval_names: List[str] = []
|
|
75
89
|
for row in rows:
|
|
@@ -99,6 +113,7 @@ def run_many(
|
|
|
99
113
|
"logs": [row["log"] for row in rows],
|
|
100
114
|
"reasons": dict(sorted(Counter(row["reason"] for row in rows).items())),
|
|
101
115
|
"outcomes": dict(sorted(Counter(_outcome_key(row["winners"]) for row in rows).items())),
|
|
116
|
+
"errors": _count_errors(rows),
|
|
102
117
|
"steps": stats([row["steps"] for row in rows]),
|
|
103
118
|
"cost_usd": {**cost_stats, "total": round(sum(costs), 10)},
|
|
104
119
|
"evals": evals_summary,
|
|
@@ -117,6 +132,7 @@ def format_summary(summary: Dict[str, Any], path: Optional[str] = None) -> str:
|
|
|
117
132
|
f"{summary['scenario']}: {summary['runs']} runs, seeds {seeds[0]} to {seeds[-1]}",
|
|
118
133
|
"reasons: " + ", ".join(f"{k} {v}" for k, v in summary["reasons"].items()),
|
|
119
134
|
"outcomes: " + ", ".join(f"{k} {v}" for k, v in summary["outcomes"].items()),
|
|
135
|
+
*(f"errors: {n}x {message}" for message, n in summary.get("errors", {}).items()),
|
|
120
136
|
f"steps: mean {steps['mean']:.2f}, stdev {steps['stdev']:.2f}, "
|
|
121
137
|
f"min {steps['min']:g}, max {steps['max']:g}",
|
|
122
138
|
f"cost: mean ${cost['mean']:.4f}, max ${cost['max']:.4f}, total ${cost['total']:.4f}",
|
|
@@ -207,7 +207,7 @@ def test_ADP_012_exponential_backoff_then_provider_error() -> None:
|
|
|
207
207
|
agent.act(dict(OX_REQUEST))
|
|
208
208
|
assert exc.value.retryable is True and exc.value.attempt == 3
|
|
209
209
|
slept = agent.slept # type: ignore[attr-defined]
|
|
210
|
-
assert len(slept) == 2 and 0
|
|
210
|
+
assert len(slept) == 2 and 1.0 <= slept[0] <= 1.5 and 2.0 <= slept[1] <= 2.5
|
|
211
211
|
|
|
212
212
|
|
|
213
213
|
def test_ADP_012_client_errors_are_not_retried() -> None:
|
|
@@ -582,3 +582,16 @@ def test_ADP_013_scripted_bots_are_free_and_deterministic(tmp_path: Path) -> Non
|
|
|
582
582
|
logs.append([e.get("action") for e in events(path) if e["type"] == "action"])
|
|
583
583
|
assert read_log(path).events[-1]["total_cost_usd"] == 0
|
|
584
584
|
assert logs[0] == logs[1]
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
def test_AGT_010_default_is_five_retries_with_about_30_seconds_of_backoff() -> None:
|
|
588
|
+
with FakeServer((429, {}, {"error": {"message": "rate limited"}})) as srv:
|
|
589
|
+
agent = oc(srv.url) # no "retries" in config
|
|
590
|
+
with pytest.raises(ProviderError, match="429") as exc:
|
|
591
|
+
agent.act(dict(OX_REQUEST))
|
|
592
|
+
slept = agent.slept # type: ignore[attr-defined]
|
|
593
|
+
assert exc.value.attempt == 6 and len(slept) == 5
|
|
594
|
+
assert 31.0 <= sum(slept) <= 33.5 # 1 + 2 + 4 + 8 + 16 seconds, plus jitter
|
|
595
|
+
for name in ("openai_compat.py", "anthropic_agent.py", "http_agent.py"):
|
|
596
|
+
text = (SRC / "agents" / name).read_text(encoding="utf-8")
|
|
597
|
+
assert '"retries", 5' in text, f"{name} must default to 5 retries"
|