AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

ChatPerplexity.Stream() Crashes With TypeError When Stop Parameter Is Passed

Calling ChatPerplexity.stream() with a stop argument raises TypeError because the integration incorrectly forwards the stop parameter to the Perplexity API as an unsupported keyword or in an unexpected type, breaking streaming and likely all calls with stop.

highConfidence 60%LangchainAgentsMemory

Origin Analysis

The ChatPerplexity class inherits streaming logic from ChatOpenAI but overrides _stream (or _generate) to build a request payload. In doing so, it likely passes the `stop` parameter directly as a top-level key to the Perplexity API, which either does not support `stop` or expects a different type (e.g., a string instead of list). This mismatch causes a TypeError when the API client tries to process the argument.
```python from langchain_perplexity import ChatPerplexity from langchain_core.messages import HumanMessage llm = ChatPerplexity(model='sonar', api_key='test') list(llm.stream([HumanMessage(content="hello")], stop=["\n"])) ```

Fixing Code Block

Edge Case Audit

This fix disables the stop functionality for Perplexity streaming; if the Perplexity API later adds stop support, this override would need to be removed or updated. Additionally, relying on warnings may go unnoticed in production. Rollback: remove the override and restore original behavior, but that will reintroduce the TypeError. Test on different API versions and with other parameters to ensure no unintended side effects.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state