agent-zero icon indicating copy to clipboard operation
agent-zero copied to clipboard

Add explicit output ceiling to Perplexity search helper

Open VamsiSudhakaran1 opened this issue 5 months ago • 1 comments

Hi maintainers — while reviewing the agent runtime, I noticed that helpers/perplexity_search.py calls the OpenAI-compatible chat completion API without an explicit output token ceiling.

Current call:

response = client.chat.completions.create(
    model=model_name,
    messages=messages,
)

This may be completely fine depending on the provider defaults, but for an agent runtime it may be safer to declare an explicit output boundary at the call site.

Why this may help:

  • makes response size more predictable
  • helps control latency and API cost
  • avoids relying only on provider/model defaults
  • makes the helper safer when used inside longer-running agent loops

Possible direction:

def perplexity_search(
    query: str,
    model_name="llama-3.1-sonar-large-128k-online",
    api_key=None,
    base_url="https://api.perplexity.ai",
    max_tokens: int = 1024,
):
    ...
    response = client.chat.completions.create(
        model=model_name,
        messages=messages,
        max_tokens=max_tokens,
    )

The exact parameter name/default can be adjusted based on the Perplexity/OpenAI-compatible API behavior.

This is not a vulnerability report — just a small release-readiness hardening suggestion for predictable cost and latency in agent workflows.

VamsiSudhakaran1 avatar Jul 05 '26 10:07 VamsiSudhakaran1

Closing due to inactivity of 90 days.

github-actions[bot] avatar Oct 09 '26 03:10 github-actions[bot]