Skip to content

enhance: add optional bounded client polling fallback#328

Merged
liujuanjuan1984 merged 1 commit intomainfrom
issue-310-eval-dev
Mar 26, 2026
Merged

enhance: add optional bounded client polling fallback#328
liujuanjuan1984 merged 1 commit intomainfrom
issue-310-eval-dev

Conversation

@liujuanjuan1984
Copy link
Copy Markdown
Collaborator

@liujuanjuan1984 liujuanjuan1984 commented Mar 26, 2026

概述

  • A2AClient.send() 增加可选且有界的 polling fallback,用于兼容 peer 返回 non-terminal task 且需要后续 tasks/get 轮询的场景
  • 保持 send_message() 的 stream-first 事件流 contract 不变,只在 send() 上做可选收敛
  • 同时收紧 send() 与文档表述,明确其返回的是 latest response event;当 fallback 启用时,可能进一步收敛为轮询得到的最终 task snapshot

Client facade

  • src/opencode_a2a/client/client.py 中为 send() 增加 bounded polling fallback
  • 仅当 send() 收到 (Task, None) 且 task state 属于 submittedworkingunknown 时触发自动轮询
  • 到达 terminal state 后返回最终 task snapshot
  • 若轮询过程中进入 input_requiredauth_required 等 caller-intervention state,则停止自动轮询并返回当前 snapshot
  • 保持现有 tasks/get 错误映射与 send_message() 事件流行为不变

Polling policy / config

  • 新增 src/opencode_a2a/client/polling.py,收敛 polling fallback 的状态判定、退避和配置校验逻辑
  • src/opencode_a2a/client/config.py 中增加以下配置项:
    • A2A_CLIENT_POLLING_FALLBACK_ENABLED
    • A2A_CLIENT_POLLING_FALLBACK_INITIAL_INTERVAL_SECONDS
    • A2A_CLIENT_POLLING_FALLBACK_MAX_INTERVAL_SECONDS
    • A2A_CLIENT_POLLING_FALLBACK_BACKOFF_MULTIPLIER
    • A2A_CLIENT_POLLING_FALLBACK_TIMEOUT_SECONDS

Tests

  • tests/client/test_client_facade.py 中补充 terminal 收敛、caller-intervention state、timeout、tasks/get 错误路径回归测试
  • tests/client/test_client_config.py 中补充新配置解析与非法参数校验
  • 新增 tests/client/test_polling.py 覆盖 polling policy helper

Docs

  • docs/guide.md 中补充 send() 的最新语义说明与 polling fallback 配置说明

验证

  • ./scripts/doctor.sh

关联

@liujuanjuan1984 liujuanjuan1984 changed the title add optional client polling fallback add optional bounded client polling fallback Mar 26, 2026
@liujuanjuan1984
Copy link
Copy Markdown
Collaborator Author

本轮基于 PR diff 的自审结论:未发现阻塞性问题。

审查要点:

  1. 需求贴合度
  • 本 PR 实现的范围与 #310 一致:只在 facade 层补可选、bounded 的 polling fallback,没有把 client 改回 sync/blocking-first,也没有改变 send_message() 的流式 contract。
  1. 设计边界
  • 触发条件限制在 (Task, None) + submitted/working/unknown,避免把 input_required/auth_required 这类 caller-intervention state 错误纳入自动轮询。
  • polling 策略已抽到独立 helper,较当前规模下是更稳妥的收口方式;没有引入额外对外 API 迁移面。
  1. 风险评估
  • 当前未发现明显遗漏、冗余或行为偏差。
  • 残余注意点是:send() 在 fallback 启用后返回的可能是轮询得到的 task snapshot,而不是原始流事件;这在当前 PR 的文档与代码表述中已明确,属于有意设计,不是隐藏行为变化。
  1. issue / PR 关系
  • Closes #310 是准确的。
  • #311#321 不应继续挂到本 PR 的关系区,因为它们已关闭且本 PR 未覆盖对应 server-side 议题。

@liujuanjuan1984 liujuanjuan1984 changed the title add optional bounded client polling fallback enhance: add optional bounded client polling fallback Mar 26, 2026
@liujuanjuan1984 liujuanjuan1984 marked this pull request as ready for review March 26, 2026 14:18
@liujuanjuan1984 liujuanjuan1984 merged commit 44cee44 into main Mar 26, 2026
3 checks passed
@liujuanjuan1984 liujuanjuan1984 deleted the issue-310-eval-dev branch March 26, 2026 14:18
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.

[Priority: Med] [Feature] Client 侧自动轮询回退机制 (GetTask)

1 participant