surfaces/.planning/phases/04-matrix-mvp-shared-agent-context-and-context-management-comma/04-01-SUMMARY.md

1 KiB

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.