feat(04-01): finalize AgentApi migration

This commit is contained in:
Mikhail Putilovskij 2026-04-17 16:31:48 +03:00
parent cd59d89617
commit 430c82dba1
9 changed files with 225 additions and 350 deletions

View file

@ -0,0 +1,29 @@
# 04-01 Summary
## Outcome
Replaced the Matrix real backend's custom `AgentSessionClient` path with a shared
`AgentApiWrapper` over upstream `lambda_agent_api.AgentApi`.
## Changes
- Added `sdk/agent_api_wrapper.py` to capture `MsgEventEnd.tokens_used` without
modifying `external/`.
- Rewrote `sdk/real.py` to use a shared `agent_api`, stream text chunks from
`AgentApi.send_message()`, and emit a final `MessageChunk` with
`last_tokens_used`.
- Updated `adapter/matrix/bot.py` to construct `RealPlatformClient` with
`AgentApiWrapper`, keep `AGENT_WS_URL` unchanged, and manage
`agent_api.connect()` / `agent_api.close()` around `sync_forever()`.
- Stubbed `sdk/agent_session.py` as a compatibility placeholder.
- Updated Matrix/runtime tests away from `thread_key` and per-request websocket
assumptions.
## Verification
- `pytest tests/platform/test_real.py -q`
- `pytest tests/adapter/matrix/test_dispatcher.py -q`
- `pytest tests/core/test_integration.py -q`
- `pytest tests/platform/test_agent_session.py -q`
All listed commands passed locally.