Core Package
Decision Node
Make typed decisions with a confidence per answer using DecisionNode and TypeSafe's Jev.
DecisionNode is an AgentNode that runs on Jev, TypeSafe's decision model, through pydantic-ai's TypeSafe model. Use it to classify, route, or score state in a workflow when you want a typed answer and a confidence, not generated text.
Jev does not generate text. The prompt is the text being judged, and each field of output_type is one question about it.
DecisionConfig
@dataclass
class DecisionConfig(AgentConfig):
model_provider: ModelProvider = ModelProvider.TYPESAFE
# Pinned so tuned confidence thresholds keep meaning the same thing.
model_name: TypeSafeModelName = "jev-1.13.0"DecisionConfig accepts every AgentConfig field. It only changes the defaults, so you usually pass just output_type. Set model_settings=TypeSafeModelSettings(...) to tune typesafe_boolean_threshold or typesafe_tool_call_threshold.
DecisionNode base class
class DecisionNode(AgentNode, ABC):
"""AgentNode on TypeSafe's Jev: typed decisions, no text generation.
Each field of `output_type` is a question. The confidence per field is in
`result.response.provider_details["confidence"]`.
"""
@abstractmethod
def get_agent_config(self) -> DecisionConfig:
passAsking questions
The field type sets the kind of question:
| Field type | Question | Answer |
|---|---|---|
Enum or Literal | Pick one option | The chosen option |
bool | Yes or no | True when the probability is at least the threshold (default 0.5) |
float with ge=0, le=1 | Yes or no | The probability itself |
IntEnum with a docstring per level | Score against a rubric | The nearest level |
list of an Enum or Literal | Yes or no per option | The selected options |
Put the question in the field description. Describe enum options with pydantic-ai's UseEnumMemberDocstrings and a docstring under each member. See the pydantic-ai TypeSafe docs for every supported type, thresholds, tools, and limits.
Implementation example
from enum import StrEnum
from pydantic import BaseModel, Field
from pydantic_ai import UseEnumMemberDocstrings
from launchpad.core.nodes.decision import DecisionConfig, DecisionNode
from launchpad.core.task import TaskContext
from launchpad.workflows.examples.decision.schema import TicketEvent
class Team(UseEnumMemberDocstrings, StrEnum):
BILLING = "billing"
"""Payments, charges, or refunds."""
TECHNICAL = "technical"
"""Errors, bugs, or login failures."""
OTHER = "other"
"""Anything else."""
class TeamQuestion(BaseModel):
"""Route a support ticket to the team that should handle it."""
team: Team = Field(description="Which team should handle this support ticket?")
class DecideTeamNode(DecisionNode):
class OutputType(DecisionNode.OutputType):
team: Team
confidence: float = Field(ge=0, le=1)
def get_agent_config(self) -> DecisionConfig:
return DecisionConfig(output_type=TeamQuestion)
async def process(self, task_context: TaskContext) -> TaskContext:
event: TicketEvent = task_context.event
result = await self.agent.run(event.message)
confidence = result.response.provider_details["confidence"]["team"]
self.save_output(
self.OutputType(team=result.output.team, confidence=confidence)
)
return task_contextKeep the question model (TeamQuestion) separate from the node's OutputType. A confidence: float field on the question model would become one more question for Jev to answer.
Confidence
Read the confidence per field from result.response.provider_details["confidence"], keyed by field name. It runs from 0 (undecided) to 1. provider_details["probabilities"] holds the full distribution for pick-one and rubric fields.
A router can branch on the saved output, for example sending low-confidence decisions to human review. Calibration is measured across many predictions, so validate thresholds on representative data before you rely on them.
Setup
Set TYPESAFE_API_KEY in the root .env for local runs, and in docker/.env for the Docker stack. pydantic-ai reads it from the environment.