Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#121 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
TypeScript
スター
2
フォーク
2
平均マージ
8時間 28分
マージ済み PR(30日)
26

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PierrunoYT/patch のほかの issue

PierrunoYT/patch の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。