feat(wrapper-py): replace amplifier-agent-client with amplifier-agent-py at protocol 0.3.0#56
Merged
Merged
Conversation
Subprocess-based wrapper mirroring amplifier-agent-ts at protocol 0.3.0. Zero engine dependency (BYO model: install amplifier-agent separately via `uv tool install amplifier-agent`). Includes: - Async + sync surface (sync via context manager pattern) - Full TS config-knob parity: configPath, workspace, displayMode, approval mode (yes/no/prompt), display.on_event callback - Version-probe gate: wrapper will refuse to communicate with mismatched engine protocol versions - 35 unit tests covering argv assembly, version checking, env allowlist / extra-override, run-output parsing, spawn/process lifecycle, and sync iterator teardown edge cases - 39 wrapper-level conformance tests exercising parse_run_output against every canonical envelope shape and parse_ndjson_stream against every documented wire-event method - 3 example applications: - diagnostic.py: binary discovery + protocol probe (no API key) - async_chat.py: full async streaming with callbacks - sync_chat.py: sync context-manager pattern - README documenting the BYO install model and env.extra opt-in for provider credentials (ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.) Fixes (caught by DTU validation): - Circular import: spawn_agent extracted into _api.py module - Provider credentials: env.extra opt-in pattern + examples - Sync teardown: explicit aclose() on iterator exit paths Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Superseded by amplifier-agent-py. The old wrapper:
- Had drifted from TS on multiple config knobs (missing configPath /
workspace / displayMode / approval mode / display.on_event)
- Pinned an older protocol version (0.2.0 vs current 0.3.0)
- Skipped the runtime protocol-version probe
- Re-introduced a hard dependency on amplifier-agent engine package
The new wrapper is a clean superset that maintains zero engine
dependency via the BYO (bring-your-own) model.
Generated with [Amplifier](https://github.com/microsoft/amplifier)
Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
The runner_py.py was already independent of the deleted amplifier-agent-client package (it inlines its own JsonRpcClient + ScriptedTransport). Updated the stale 'Phase B' comment to describe the runner's current role: protocol-level wire-fixture replay that validates the engine's JSON-RPC wire contract. Added pointer to wrapper-level conformance tests under wrappers/python-py/tests/conformance/. Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Cosmetic-only whitespace cleanup — collapse a multi-line dict that fit within line-length back onto a single line. No behavior change. 🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This work replaces the legacy
amplifier-agent-clientPython wrapper with a clean, dependency-free new wrapperamplifier-agent-pythat mirrors the TypeScript wrapper one-to-one.What Changed
Commit 1: New wrapper —
wrappers/python-py/with 74 unit tests, 39 conformance tests, and 3 working examples (diagnostic, async chat, sync chat). Full TS config-knob parity:configPath,workspace,displayMode, approval mode,display.on_eventcallback. Zero engine dependency via BYO (bring-your-own) install model.Commit 2: Old wrapper removed —
wrappers/python/(24 files). The old wrapper had drifted from TS (missing config knobs), pinned an older protocol (0.2.0 vs 0.3.0), skipped version probe, and re-introduced engine dependency.Commit 3: Conformance clarity — Updated
runner_py.pydocstring. The runner was already independent (inlines its own JSON-RPC client). Clarified scope and pointed to new wrapper-level tests.DTU Validation
The work was validated end-to-end in a Digital Twin Universe environment (engine and wrapper installed in isolation). Three runtime bugs were caught by the DTU and fixed:
__init__.py↔sync.py→ resolved by extractingspawn_agentinto_api.pyenv.extrapattern + examples calloutGeneratorExitignored during teardown → resolved by explicitaclose()on all exit paths, 4 new regression testsTest Coverage
No Breaking Changes
amplifier-agent) unchangedamplifier-agent-ts) unchangedMigration Guide
Users migrating from the old wrapper should:
pip uninstall amplifier-agent-clientpip install amplifier-agent-pyamplifier_agent_pyinstead ofamplifier_agent_clientenv={"extra": {"ANTHROPIC_API_KEY": "..."}}or rely on host envSee
wrappers/python-py/README.mdfor full usage documentation.