Skip to content

feat(wrapper-py): replace amplifier-agent-client with amplifier-agent-py at protocol 0.3.0#56

Merged
manojp99 merged 4 commits into
mainfrom
feat/amplifier-agent-py-wrapper
Jun 15, 2026
Merged

feat(wrapper-py): replace amplifier-agent-client with amplifier-agent-py at protocol 0.3.0#56
manojp99 merged 4 commits into
mainfrom
feat/amplifier-agent-py-wrapper

Conversation

@manojp99

Copy link
Copy Markdown
Collaborator

Summary

This work replaces the legacy amplifier-agent-client Python wrapper with a clean, dependency-free new wrapper amplifier-agent-py that mirrors the TypeScript wrapper one-to-one.

What Changed

Commit 1: New wrapperwrappers/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_event callback. Zero engine dependency via BYO (bring-your-own) install model.

Commit 2: Old wrapper removedwrappers/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.py docstring. 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:

  1. Circular import__init__.pysync.py → resolved by extracting spawn_agent into _api.py
  2. Credentials silently stripped — Provider keys filtered by env allowlist → resolved by opt-in env.extra pattern + examples callout
  3. Sync iterator early-break leakGeneratorExit ignored during teardown → resolved by explicit aclose() on all exit paths, 4 new regression tests

Test Coverage

  • New wrapper: 74 unit tests (argv, version check, spawn/env, run-output parsing, sync teardown)
  • Conformance: 39 tests exercising every canonical envelope and wire-event method
  • All pass in DTU and locally

No Breaking Changes

  • Engine (amplifier-agent) unchanged
  • TS wrapper (amplifier-agent-ts) unchanged
  • Protocol version (0.3.0) unchanged

Migration Guide

Users migrating from the old wrapper should:

  1. pip uninstall amplifier-agent-client
  2. pip install amplifier-agent-py
  3. Import from amplifier_agent_py instead of amplifier_agent_client
  4. Credentials: pass via env={"extra": {"ANTHROPIC_API_KEY": "..."}} or rely on host env

See wrappers/python-py/README.md for full usage documentation.

Manoj Prabhakar Paidiparthy and others added 4 commits June 13, 2026 22:16
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>
@manojp99 manojp99 merged commit ac8290a into main Jun 15, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant