fix(server): add bounded outbound client cache lifecycle#294
Merged
liujuanjuan1984 merged 2 commits intomainfrom Mar 23, 2026
Merged
fix(server): add bounded outbound client cache lifecycle#294liujuanjuan1984 merged 2 commits intomainfrom
liujuanjuan1984 merged 2 commits intomainfrom
Conversation
Collaborator
Author
|
本轮基于 PR diff 做了代码审查,结论如下。
|
Collaborator
Author
|
补充修复了上一轮 reviewer 视角下发现的两个问题:
补充测试:
验证:
|
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.
概述
本 PR 解决
A2AClientManageroutbound client 缓存无界增长的问题,引入受控缓存与显式借用生命周期,避免在长期高频调用或多 peer 交互时仅增不减地持有A2AClient/httpx.AsyncClient。按模块说明
src/opencode_a2a/config.pyA2A_CLIENT_CACHE_TTL_SECONDSA2A_CLIENT_CACHE_MAXSIZEsrc/opencode_a2a/server/application.pyA2AClientManager从无界dict[str, A2AClient]调整为受控缓存last_used / expires_at / pending_evictionborrow_client(),统一管理借用前后状态刷新与回收src/opencode_a2a/client/client.py_active_requests与is_busy()send_message / get_task / cancel_task / resubscribe_task周围统一记录 in-flight usagesrc/opencode_a2a/execution/executor.pya2a_call从get_client()切到async with mgr.borrow_client(url)测试
tests/server/test_a2a_client_manager.pytests/server/test_transport_contract.pyA2AClientManagertests/execution/test_opencode_agent_session_binding.pyborrow_client()接口验证
uv run pre-commit run --all-filesuv run pytest339 passedcoverage 91.08%关联
Closes #287