feat(perplexity): add Agent API presets and deprecate legacy Sonar models - #178
Draft
andrewmadson-pplx wants to merge 10 commits into
Draft
feat(perplexity): add Agent API presets and deprecate legacy Sonar models#178andrewmadson-pplx wants to merge 10 commits into
andrewmadson-pplx wants to merge 10 commits into
Conversation
andrewmadson-pplx
marked this pull request as draft
August 28, 2026 22:21
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.
Summary
Adds Perplexity Agent API support to the public BaseAI OSS local runtime while preserving the existing Sonar Chat Completions path during the migration window.
What changed
perplexity:fast,perplexity:low,perplexity:medium, andperplexity:high.POST https://api.perplexity.ai/v1/agentwith the matching preset./chat/completionstransport; existing Pipes are not migrated automatically.main.The initial adapter supports system, user, and assistant text; non-streaming responses; streaming answer text; preset search; and non-streaming citation metadata. It does not yet support custom tools, tool-result replay, background runs, file outputs, explicit Agent model selection, image content, or streamed citation metadata.
OSS-only scope
This PR is intentionally limited to BaseAI's public open-source local runtime, public types, tests, examples, and documentation.
This PR changes only the public BaseAI local runtime; Langbase-hosted execution and rollout are outside its scope.
Migration notes
The provider documentation includes a before/after Pipe example, environment-key guidance, local commands, preset-selection guidance, supported and unsupported behavior, the Agent API quickstart, and the Sonar migration guide.
BaseAI's required
max_tokens,temperature, andtop_pvalues are forwarded to Agent API (max_tokensbecomesmax_output_tokens) and therefore override the chosen preset's tuned defaults. Migrating users should review those values.Adversarial-review follow-up
Resolved on the current head:
perplexity:xhigh,perplexity:wide-research, and typo identifiers return 400 without calling either Perplexity endpoint.status: "failed"returns 500 while the existing non-2xx provider mappings remain intact.runner.done()and sets a nonzero process exit code on failure.Not implemented without live evidence:
finish_reason: "length", but the public Perplexity documentation does not identify the exact incomplete terminal SSE discriminator. The stream parser will not guess that contract.Verification
Passed on the current branch:
pnpm install --frozen-lockfile— passed.pnpm --filter baseai test:node— 6 files, 91/91 tests, no type errors.pnpm --filter baseai test:edge— 5 files, 88/88 tests, no type errors.pnpm --filter baseai exec vitest --config vitest.node.config.js --run src/dev/routes/v1/pipes/run.perplexity.test.ts— 21/21 route-level cases.pnpm --filter baseai exec vitest --config vitest.edge.config.js --run src/dev/routes/v1/pipes/run.perplexity.test.ts— 21/21 route-level cases.pnpm --filter @baseai/core exec vitest --config vitest.node.config.js --run src/pipes/pipes.streaming.test.ts— 1/1.pnpm --filter @baseai/core exec vitest --config vitest.edge.config.js --run src/pipes/pipes.streaming.test.ts— 1/1.pnpm --filter baseai build— passed.pnpm --filter @baseai/core build— passed.pnpm --filter example-nodejs check— workspace-linked build, type-check, and CLI check passed.pnpm --filter baseai.dev build— production docs build passed with existing warnings.pnpm changeset status --since=main— validates minor bumps forbaseaiand@baseai/core.git diff --check— passed.main— no diff.The full Core suite still has four stale
pipe.generateText/pipe.streamTextfailures. The same four failures reproduce onmain. Repository-wide type-check, lint, and formatting commands also retain existingmainfailures; the new targeted checks and builds pass.The pull request currently has no GitHub check runs attached.
Fixtures and live validation
The golden response and SSE fixtures are sanitized, documentation-derived contract examples assembled from the current public Agent API schema and migration documentation. They are not captured live responses.
No Perplexity credential is available in the protected environment, and no billable-call authorization or call ceiling has been supplied for this follow-up. No live request was made.
Before moving this PR out of draft:
perplexity:fastresponse with citations.perplexity:fastevent sequence.This PR intentionally remains a draft and is not ready to merge until the live contract and token-limit acceptance items are completed or explicitly waived.