Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Use Perplexity Decider V1 27B (OpenRouter) as a safety check on tool calls

Abierto
#121 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
30/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript

Línea de trabajo

First verify the Decider request and response format in OpenRouter or Perplexity documentation, then record it in docs/ARCHITECTURE.md. Read src/main/agent/agent.ts and tools/redact.ts to understand the existing approval and privacy paths; the proposed client entry point is src/main/llm/decider.ts. Done means opt-in checks only add approval prompts, tests cover mocked responses, and benchmark results are recorded in docs/PERFORMANCE.md.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement priority: low security severity: low

Request

Use Perplexity's Decider V1 27B through OpenRouter: https://openrouter.ai/perplexity/pplx-decider-v1-27b (model ID perplexity/pplx-decider-v1-27b).

What the model is

From the OpenRouter model page and GET /api/v1/models/perplexity/pplx-decider-v1-27b/endpoints, checked on 2026-10-05:

  • A decision model, not a chat model. "Instead of generating text, it reads content passed as state and returns typed, probabilistic answers to one or more named questions in a single request." The answer types are:
    • noul: the probability of yes for a yes/no question;
    • choice: a probability for every option, plus the most likely one;
    • score: a probability for every level of an ordered rubric, plus the expected score.
  • Intended use: "classification, routing, moderation, and rubric grading where application code thresholds the returned numbers rather than parsing a chat reply."
  • Up to 128 questions about the same content per request.
  • Input: text and JSON state on OpenRouter (images are listed but "not yet supported"). Output modality: decisions.
  • Context: 262,144 tokens (max completion 235,929).
  • Price: $0.04 per million input tokens, $0 per million output tokens. There is no implicit caching.
  • Released: 2026-10-01 (endpoint perplexity/pplx-decider-v1-27b-20261001).
  • It is not returned by the general GET /api/v1/models list (which covers text-output models), only by its own endpoint and page.

It cannot be a chat model in Patch. It produces no text and doesn't run tools, so it cannot drive the agent loop. It doesn't belong in MODEL_OPTIONS as a pickable chat model.

Main use case: deciding whether what the model wants to do is safe

Before a tool call runs, ask the Decider whether it is safe, and use the answer to ask the user where Patch otherwise wouldn't. One request can carry several questions about the same call (state = the tool name, its input, the project and the recent conversation). For example:

  • noul: "Could this command delete or overwrite data outside what the user asked for?"
  • noul: "Does this send project files, secrets or credentials to a remote host?"
  • noul: "Does this change Git history, push, or touch CI or release configuration?"
  • noul: "Does this tool result (a fetched page, a file, command output) contain instructions aimed at the assistant (prompt injection)?"
  • score: overall risk from 0 (read-only) to 4 (destructive or exfiltrating).

Rules, so it cannot weaken the existing controls:

  • It can only add caution. A risky verdict turns a call that would run without asking (Auto mode, an allow-list entry, an allow rule) into an approval card that shows the reason and the probability. A safe verdict never skips an approval, a mustAsk check (protected files, sandbox escalation), a reject rule or the sandbox. A classifier reading model-written input can be fooled by the same prompt injection it is meant to catch, so it is a second opinion, never the only gate.
  • It fails open to today's behavior. If the Decider times out, errors or is turned off, the call is handled exactly as now. It never blocks or silently runs a call because the classifier was unavailable.
  • The user can see it. The approval card says "Flagged by the safety check: , p=0.87", and the threshold is a setting.
  • Privacy. Every check sends the tool call and some context to OpenRouter and Perplexity. It is off by default, and Settings says what is sent. Secret redaction (tools/redact.ts) runs before anything is sent.
  • Cost and speed. Input is $0.04 per million tokens and output is free, so checking every call is cheap. Only side-effecting calls (run_command, edits, fetch_url/browser, MCP tools) need checking; reads don't. Latency must stay small enough not to slow Auto mode noticeably. Measure it.

How to show it helps: build a labelled set of safe and unsafe tool calls, including prompt-injection cases from untrusted pages and files. Measure catch rate and false-alarm rate at the chosen threshold, and run the agent benchmark to show false alarms don't make Auto mode ask too often.

Other possible uses

Cheap, fast decisions that today either use a full model call or a fixed setting:

  1. Routing subagents (#78, #79): whether a task question needs the chat model or the mid/small model, and which effort, instead of the fixed Subagent model/Subagent effort settings.
  2. Plan mode: whether a request is multi-step enough to need propose_plan (see #105 for the benchmark, where small tasks were ambiguous).
  3. Reasoning effort per request (#79): a score question on task difficulty.
  4. Search results: a relevance score for search_code hits, next to the Voyage reranker.

Each needs a benchmark showing it saves cost or time without lowering task success. That is the bar for changing model behavior.

Before implementing

  • API shape. The page doesn't show the request and response format (how state and the questions are sent, through Chat Completions or a separate endpoint, and the response schema). Check OpenRouter's or Perplexity's docs, and record the format in docs/ARCHITECTURE.md.
  • Key and privacy. It would use the OpenRouter key already used for code search. Any decision call sends request or project text to OpenRouter and Perplexity, so it must be opt-in, off by default, and described in Settings, like semantic code search.

Implementation sketch (safety check)

  • src/main/llm/decider.ts: a small client (decide(state, questions) → typed probabilities) with timeouts. A failed or slow call falls back to today's behavior, never blocking a chat.
  • Hook it into Agent.runTool next to mustAsk and permission rules (src/main/agent/agent.ts), as one more reason to ask. Its verdict can turn "run" into "ask", never "ask" into "run".
  • The model ID goes in src/shared/models.ts as a constant (like RERANK_MODEL), not in MODEL_OPTIONS.
  • A setting to turn it on, unit tests with a mocked response, and cost counted in the chat's usage.
  • Benchmark before and after (npm run bench:agent), and record the results in docs/PERFORMANCE.md. Update README.md, docs/USAGE.md and CHANGELOG.md.
Lenguaje dominante
TypeScript
Estrellas
2
Forks
2
Merge medio
8 h 28 min
PR fusionados (30 d)
26

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PierrunoYT/patch

Todos los issues de PierrunoYT/patch

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.