Skip to content

fix(cli,lib): wire PROTOCOL_VERSION import + track pyproject for __version__ - #22

Merged
manojp99 merged 1 commit into
mainfrom
fix/version-info-and-error-message
May 29, 2026
Merged

fix(cli,lib): wire PROTOCOL_VERSION import + track pyproject for __version__#22
manojp99 merged 1 commit into
mainfrom
fix/version-info-and-error-message

Conversation

@manojp99

Copy link
Copy Markdown
Collaborator

What. Three drift fixes on the amplifier-agent version surface. (1) admin/version_info.py had a hardcoded PROTOCOL_VERSION = "0.1.0" left behind from before the 0.2.0 protocol bump (commit ea51d05), causing amplifier-agent version --json to advertise a wire version the engine no longer speaks. It now imports PROTOCOL_VERSION directly from amplifier_agent_lib.protocol — the same constant the engine and modes/single_turn.py already use as truth — so the two can never drift again. (2) amplifier_agent_lib.__version__ was hardcoded to "0.2.0" while pyproject.toml had moved to 0.3.0, so version, --version, the serverInfo payload, and the prepared-bundle cache key all reported a stale version. It now resolves via importlib.metadata.version("amplifier-agent") with a hardcoded fallback only for the source-tree-without-dist-info edge case. (3) Three tests still asserted "0.1.0" post-protocol bump; updated to "0.2.0", and test_cli_version_subcommand.py now imports PROTOCOL_VERSION from the protocol package so it cannot go stale again.

Why. The reality-check that surfaced these caught two user-visible lies on a published-facing endpoint: wrappers do pre-spawn protocol probes via version --json, so a wrong protocolVersion payload risks engine/wrapper handshake failures with confusing diagnostics. Tying __version__ to packaging metadata (rather than restating it) also closes the door on every future drift instance — including in places we didn't touch this round (engine serverInfo, cache key, doctor output).

How verified. uv run amplifier-agent version --json now emits {"version": "0.3.0", "protocolVersion": "0.2.0"} matching pyproject.toml and protocol/methods.py respectively. uv run amplifier-agent --version emits amplifier-agent, version 0.3.0. Targeted pytest pass (34/34) across the affected test files; full suite passes everywhere it passed on main (22 pre-existing failures unrelated to this PR — Mode A v2 envelope, --mcp-servers flag, spec.md staleness — exist before and after). python_check clean on all changed files.

…rsion__

- admin/version_info.py: import PROTOCOL_VERSION from amplifier_agent_lib.protocol
  instead of hardcoding "0.1.0". This fixes the lie in `amplifier-agent version --json`
  which reported wire 0.1.0 while the engine speaks 0.2.0 (surfaced by reality-check).
  Prevents future drift: now uses the same source of truth as modes/single_turn.py.

- amplifier_agent_lib.__version__: resolve from importlib.metadata instead of
  hardcoding "0.2.0" vs pyproject.toml's "0.3.0". Fixes --version, version command,
  serverInfo payload, and prepared-bundle cache key reporting stale version.

- tests: update protocol version assertions from 0.1.0 to 0.2.0 after ea51d05 bump.
  test_cli_version_subcommand.py now imports PROTOCOL_VERSION from protocol package
  so it can never go stale again.

Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
@manojp99
manojp99 merged commit 2c25413 into main May 29, 2026
1 of 3 checks passed
manojp99 added a commit that referenced this pull request May 29, 2026
…_API_KEY, accept legacy AZURE_OPENAI_KEY) (#23)

Aligns the CLI's Azure provider detection with the rest of the project. The README,
architecture presentation, cheatsheet, upstream amplifier-module-provider-azure-openai,
and Azure OpenAI Python SDK all use AZURE_OPENAI_API_KEY, but the CLI was only honoring
AZURE_OPENAI_KEY. After this change, the CLI prefers AZURE_OPENAI_API_KEY, accepts
AZURE_OPENAI_KEY as a deprecated legacy alias with a one-time [WARN] on stderr,
and preserves detection precedence (ANTHROPIC_API_KEY > OPENAI_API_KEY > AZURE_OPENAI_API_KEY > OLLAMA_HOST).

Mirrors the upstream Azure provider module's dual-accept pattern (see __init__.py lines 119-120),
which already prefers AZURE_OPENAI_API_KEY and falls back to AZURE_OPENAI_KEY.

Verification: python_check clean on all 8 changed .py files, 53 tests pass on targeted
test suite, full pytest shows same 23 pre-existing failures as origin/main (+2 new tests
passing, no new failures). Manual verification confirms detection works with both spellings,
legacy fallback triggers deprecation warning.

Separate from PR #22 (version-info-and-error-message).

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-authored-by: Manoj Prabhakar Paidiparthy <mpaidiparthy@microsoft.com>
Co-authored-by: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
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