Skip to content

fix(moa): route MoA provider through in-process facade in streaming path - #67420

Closed
wangzengzhi wants to merge 2 commits into
NousResearch:mainfrom
wangzengzhi:fix/moa-streaming-custom-provider
Closed

fix(moa): route MoA provider through in-process facade in streaming path#67420
wangzengzhi wants to merge 2 commits into
NousResearch:mainfrom
wangzengzhi:fix/moa-streaming-custom-provider

Conversation

@wangzengzhi

Copy link
Copy Markdown

The non-streaming code path (chat_completion_helpers.py line ~423) already
handles provider='moa' correctly by calling agent.client.chat.completions.create()
through the MoAClient facade. The streaming path in interruptible_streaming_api_call
was missing this check, causing it to build an HTTP client targeting the
virtual 'moa://local' URL, resulting in 404 errors on platforms with stream
consumers (Feishu, WeChat).

This fix adds the same provider=='moa' guard to the streaming path, making
MoA work consistently across both streaming and non-streaming scenarios.

lark-oapi 1.6.8 does not expose the `extra_ua_tags` kwarg on its

websocket Client, so origin/main's Feishu adapter fails when it passes

`extra_ua_tags=["channel"]`. 1.6.9 adds support for the parameter.

This lets the Feishu WebSocket connection request the Channel protocol

for group @mention delivery without needing a runtime compatibility shim.
The non-streaming code path (chat_completion_helpers.py line ~423) already
handles provider='moa' correctly by calling agent.client.chat.completions.create()
through the MoAClient facade. The streaming path in interruptible_streaming_api_call
was missing this check, causing it to build an HTTP client targeting the
virtual 'moa://local' URL, resulting in 404 errors on platforms with stream
consumers (Feishu, WeChat).

This fix adds the same provider=='moa' guard to the streaming path, making
MoA work consistently across both streaming and non-streaming scenarios.
@wangzengzhi
wangzengzhi requested a review from a team July 19, 2026 10:16
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint platform/feishu Feishu / Lark adapter P3 Low — cosmetic, nice to have needs-decision Awaiting maintainer decision before any implementation labels Jul 19, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to closed streaming predecessors #57314/#57328 and the merged non-streaming facade fix #53826. This is an active reimplementation, not a duplicate of closed work. The unrelated lark-oapi version bump should be split or justified.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracing the virtual-provider path.

Problems

  • Current main already provides the reported streaming behavior: agent/chat_completion_helpers.py:2334 calls _create_request_openai_client(), and run_agent.py:4201-4202 returns the existing MoA facade for provider == "moa". This was added by 66aeda35501d4998fddbc87fde92b3c25d1b4486 (fix(moa): keep virtual provider on MoA client). The new direct streaming branch therefore duplicates the current shared routing behavior.
  • The lark-oapi pin change is independent of this MoA fix. As noted in the existing review discussion, please split it into a focused Feishu dependency change or document its validation separately.

Suggested changes

  • Drop the redundant MoA branch and retain the shared helper route.
  • Split or independently justify the Feishu dependency update.

Automated hermes-sweeper review.

# MoA provider special handling: route through the in-process facade
# to support custom reference models and aggregators without hitting
# the virtual "moa://local" HTTP endpoint.
if agent.provider == "moa":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current main already reaches the MoA facade through the shared helper: _create_request_openai_client() returns the primary client for provider == "moa" (run_agent.py:4201-4202). This branch duplicates that behavior; keeping the common route preserves one request-client lifecycle path.

Comment thread pyproject.toml
]
dingtalk = ["dingtalk-stream==0.24.3", "alibabacloud-dingtalk==2.2.42", "qrcode==7.4.2"]
feishu = ["lark-oapi==1.6.8", "qrcode==7.4.2"]
feishu = ["lark-oapi==1.6.9", "qrcode==7.4.2"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Feishu SDK update is unrelated to the MoA streaming change. Please split it into a focused dependency fix or add dedicated justification and validation in that scoped change.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform area/streaming Streaming responses: gateway delivery, provider wire labels Jul 19, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Closing — the fix this PR proposes is already on current main: _create_request_openai_client (run_agent.py) short-circuits provider == "moa" and returns the in-process facade (landed via #53826, commit 66aeda3), and the streaming path routes through it. Verified live on today's main. Note for future PRs: the branch also bundles an unrelated lark-oapi 1.6.8→1.6.9 bump in pyproject.toml/uv.lock — dependency changes should never ride inside a fix PR. Thanks for the report-with-repro regardless!

@teknium1 teknium1 closed this Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/streaming Streaming responses: gateway delivery, provider wire comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have platform/feishu Feishu / Lark adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants