> For the complete documentation index, see [llms.txt](https://agpt.co/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://agpt.co/docs/integrations/block-integrations/pick_best.md).

# Typesafe Pick Best

Select an original candidate and rank alternatives using Jev's returned probabilities.

## Jev Pick Best

### What it is

Choose the best candidate using Jev and rank candidates directly by its probabilities. State the comparison criteria in plain language.

### How it works

The block turns at least two candidates into Choice options named `candidate_1`, `candidate_2`, and so on. Candidate descriptions are compact JSON text capped at 2,000 characters each; any truncation is reported. Jev evaluates those options against the question and state, and the winning label maps back to the unchanged original candidate and its zero-based `best_index`.

`ranked` contains the original candidates ordered directly by descending returned probability, retaining input order for ties. It does not adjust the model's answers. The shared transparency outputs show the exact candidate descriptions that were sent. A failed call emits an error without selecting or ranking candidates.

### Inputs

| Input      | Description                                                                                                                                     | Type       | Required |
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | -------- |
| state      | Text or JSON context shared by every question in this stateless call. JSON is compactly serialized; oversized context is truncated with a note. | State      | No       |
| candidates | Candidates to compare; descriptions are compact JSON capped at 2,000 characters each.                                                           | List\[Any] | Yes      |
| question   | Plain-language comparison, for example: Which candidate best meets the requirements in the state?                                               | str        | Yes      |

### Outputs

| Output           | Description                                                                                                                                    | Type              |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
| error            | API failure details; emitted only when a call fails.                                                                                           | str               |
| request          | Verbatim JSON request body sent to Jev.                                                                                                        | str               |
| response         | Verbatim UTF-8 response body from Jev, or null if no response arrived. Invalid UTF-8 is preserved as a lossless Base64 data URL with an error. | str               |
| latency\_ms      | Wall-clock API call duration in ms.                                                                                                            | float             |
| input\_tokens    | Input tokens reported by the API, or null if unavailable on failure.                                                                           | int               |
| output\_tokens   | Output tokens reported by the API, or null if unavailable on failure.                                                                          | int               |
| request\_id      | TypeSafe request ID response header.                                                                                                           | str               |
| truncated        | Whether any input text was truncated.                                                                                                          | bool              |
| truncation\_note | Truncation details, or an empty string.                                                                                                        | str               |
| best             | Original candidate selected by Jev.                                                                                                            | Best              |
| best\_index      | Zero-based index of the selected candidate.                                                                                                    | int               |
| ranked           | Original candidates sorted by returned probability, highest first; ties retain input order.                                                    | List\[Any]        |
| probabilities    | Probabilities keyed by candidate\_1, candidate\_2, and so on.                                                                                  | Dict\[str, float] |

### Possible use case

**Response Selection**: Choose which prepared support reply best addresses the customer's stated problem.

**Search Result Selection**: Rank retrieved passages by how well they support a specific question.

**Action Comparison**: Select among proposed workflow actions using requirements supplied in the state.

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://agpt.co/docs/integrations/block-integrations/pick_best.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
