Skip to content

fix(pi): keep silent bounded streams alive - #360

Merged
FumingZhang merged 1 commit into
mainfrom
fix/pi-stream-keepalive
Oct 29, 2026
Merged

FumingZhang merged 1 commit into
mainfrom
fix/pi-stream-keepalive

Conversation

@FumingZhang

Copy link
Copy Markdown
Member

Summary

Send bounded SSE keepalive comments every 15 seconds while Pi is performing model prefill or tool work without text output. The Portal already forwards these comments; this prevents its idle transport from closing an otherwise active streaming task.

Stop the keepalive timer on completion, failure or cancellation. Keep the existing two-minute task deadline, eight-tool budget, output/backpressure limits and no-retry behavior. Add silent-stream completion/cancellation regressions and document the contract.

Related issue

Follow-up from the maintainer-requested validation of the real Pi harness alongside #354. This adapter code is identical on main, so the focused repair targets main and has no dependency on the common-executor feature branch.

Validation

Node 24.18.0, npm 12.0.1 and the locked Pi SDK 0.87.1 were used. Commands are relative to the repository root.

Command: node --test --test-name-pattern='silent streaming work' examples/pi-agent/test/server.test.mjs
Result: reproduced the missing keepalive before the repair.

Command: npm --prefix examples/pi-agent ci --offline --ignore-scripts --no-audit --no-fund
Result: failed because one locked package was absent from the local cache.

Command: npm --prefix examples/pi-agent ci --ignore-scripts --no-audit --no-fund
Result: passed using the public npm registry; no dependency or lockfile change.

Command: npm --prefix examples/pi-agent test
Result: passed, 22 tests; four existing image-only checks were skipped by their own prerequisites. The initial fresh-worktree run reported the missing SDK before dependency restoration.

Command: npm --prefix examples/pi-agent run check
Result: passed.

Command: make docs-check
Result: passed, including 43 generated HTML pages and source headers.

Command: git diff --cached --check
Result: passed.

Not run: a patched live model/tool acceptance or image-only checks at PR creation; neither is claimed as passed here.

Authorized live evidence before the repair: an actual Pi streaming request emitted its initial role event, then remained silent during active model prefill. The Portal correctly closed the idle upstream connection at approximately 60 seconds. This change adds liveness frames rather than lengthening either timeout or retrying the request. Failed attempts were retained; no private logs, prompts, credentials or deployment coordinates are attached.

Compatibility and operational impact

Only streaming responses from the Pi example gain SSE comments. Comments are not model output and do not indicate that a task completed. Non-streaming behavior, model permissions, credentials, tool execution, cancellation, deadlines and retry policy are unchanged. Keepalives count toward the bounded wire output.

No CRD or dependency change. Maintainer review and the new PR's CI/CLA checks are still required.

Checklist

  • The change is focused and preserves unrelated work.
  • Tests cover the changed behavior, or I explained why no new test is needed.
  • Documentation and examples match any public behavior changes.
  • Generated artifacts were updated from source, or none are affected.
  • Dependency changes include lockfiles, source attribution, and license information, or none are affected.
  • I checked the diff and attachments for secrets, private endpoints or identifiers, customer data, agent conversations, and internal information.
  • I followed the applicable CLA instructions, or asked a maintainer about an unclear check.
  • I identified checks that need credentials or a live environment and did not run them without authorization.

Send bounded SSE keepalives during model prefill and tool work so idle transports do not close an active request. Stop the timer on completion or cancellation while retaining the two-minute task deadline and no-retry behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@feiskyer Pengfei Ni (feiskyer) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@FumingZhang
FumingZhang merged commit e819369 into main Oct 29, 2026
26 checks passed
@FumingZhang
FumingZhang deleted the fix/pi-stream-keepalive branch October 29, 2026 23:20
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.

2 participants