Skip to content

fix: deliver reply for SDK-routed providers - #800

Merged
superdav42 merged 1 commit into
mainfrom
fix/sdk-provider-reply-flush
Apr 7, 2026
Merged

superdav42 merged 1 commit into
mainfrom
fix/sdk-provider-reply-flush

Conversation

@superdav42

Copy link
Copy Markdown
Contributor

Providers routed through the WP AI Client SDK (everything except the hardcoded openai/anthropic/google/openai-compat direct paths) call generate_text_result() which is non-streaming. The REST controller's SSE response only commits text the frontend assembled from token events, so SDK provider replies were silently dropped on the wire — the user saw the loop complete with iterations_used=1 but no assistant message in the chat.

Track whether the streaming direct path already pushed tokens via a reply_streamed flag on AgentLoop, exposed via reply_was_streamed(). In handle_stream, after run() returns, push the reply text as a single token before sending done whenever streaming did not happen. This is a temporary bridge — see ai-agent#TBD for the full strip of the bespoke direct paths in favour of SDK-only routing.

Providers routed through the WP AI Client SDK (everything except the
hardcoded openai/anthropic/google/openai-compat direct paths) call
generate_text_result() which is non-streaming. The REST controller's
SSE response only commits text the frontend assembled from `token`
events, so SDK provider replies were silently dropped on the wire —
the user saw the loop complete with iterations_used=1 but no
assistant message in the chat.

Track whether the streaming direct path already pushed tokens via a
`reply_streamed` flag on AgentLoop, exposed via reply_was_streamed().
In handle_stream, after run() returns, push the reply text as a
single token before sending `done` whenever streaming did not happen.
This is a temporary bridge — see ai-agent#TBD for the full strip
of the bespoke direct paths in favour of SDK-only routing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the bug Auto-created from TODO.md tag label Apr 7, 2026
@superdav42
superdav42 merged commit 1cff2c1 into main Apr 7, 2026
12 of 21 checks passed
superdav42 added a commit that referenced this pull request Apr 7, 2026
Removes all direct provider implementations (OpenAI, Anthropic, Google,
OpenAI-compatible HTTP fallback) and the SSE streaming layer from AgentLoop
and RestController. All requests now route through wp_ai_client_prompt() —
provider auth, model resolution, and transport are entirely the SDK's
responsibility.

The /stream SSE endpoint is replaced by /chat which returns a standard
WP_REST_Response. generate_session_title() is updated to use the SDK
instead of per-provider HTTP calls.

Resolves the merge conflict with #800 by rebasing onto main and applying
the PR #801 changes cleanly.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
superdav42 added a commit that referenced this pull request Apr 7, 2026
Removes all direct provider implementations (OpenAI, Anthropic, Google,
OpenAI-compatible HTTP fallback) and the SSE streaming layer from AgentLoop
and RestController. All requests now route through wp_ai_client_prompt() —
provider auth, model resolution, and transport are entirely the SDK's
responsibility.

The /stream SSE endpoint is replaced by /chat which returns a standard
WP_REST_Response. generate_session_title() is updated to use the SDK
instead of per-provider HTTP calls.

Resolves the merge conflict with #800 by rebasing onto main and applying
the PR #801 changes cleanly.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant