feat(ask): handle PAI stream events (session/result/cost/done) - #29
Open
Priyanshu (priyanshu-plivo) wants to merge 3 commits into
Open
feat(ask): handle PAI stream events (session/result/cost/done)#29Priyanshu (priyanshu-plivo) wants to merge 3 commits into
Priyanshu (priyanshu-plivo) wants to merge 3 commits into
Conversation
Prep the CLI Buddy client for the PAI streaming contract, alongside the legacy token/final events (backward-compatible): - result: complete sanitized answer (no deltas) — rendered as a block - session: capture session_id; buddySession replays it on the next -i turn - cost: total_cost_usd shown only in --verbose (passes through in -o json) - done: ends the stream (also terminates -o json mode) buddyInner already falls back to the raw payload, so unwrapped PAI frames parse without an envelope change. Adds table tests.
The ubuntu-latest-m-plivo managed runner pool has been unavailable since Jul 7 — smoke/lint/codeql jobs sat queued and GitHub auto-cancelled them at the 24h timeout, blocking every PR. These jobs only run gofmt/vet/ go test/build + dry-run smoke checks on public deps (no internal network), and pages.yml already uses ubuntu-latest in this repo, so GitHub-hosted runners are sufficient. Revert to -m-plivo once that pool is healthy if the team prefers it.
This reverts commit 865c0e6.
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.
What
Prep the
plivo askBuddy client for the PAI streaming contract, backward-compatible with today'stoken/finalevents.Contract (verified live against prod pai-voice customer endpoint)
Raw SSE —
data:is the bare object (NOT the{type,data}wrapper):session {session_id}·result {text}(complete answer, no deltas) ·cost {total_cost_usd}·done {}· heartbeats =:-comment lines (already skipped by the SSE reader).Changes
internal/api/types.go: addsession_idtoBuddyChatRequest.cmd/buddy.gobuddyRenderer: handleresult(render as block),session(capture for continuation),cost(verbose/-o jsononly — hidden in normal output),done(terminate; also ends-o json).buddyInneralready falls back to the raw payload, so unwrapped frames parse with no envelope change.buddySession(-i): capturesession_idand replay it on the next turn; cleared on/reset.Testing
cmd/apisuites,-raceclean.plivobinary vs a mock emitting the exact prod frames → JSON passthrough ✓, human-mode block render ✓, cost hidden (shown in--verbose) ✓, cleandonetermination ✓.Open questions (for the PAI/aiassist owner)
{type,data}wrapper? (Coded for both.)session_id?costconfirmed internal-only / never shown to customers?result(notoken)?Pairs with contacto-console PR (same contract in the web Buddy chat).