Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Added

- **TypeSafe classifier routing** — new `type_safe_classifier` route type
routes through TypeSafe's Jev "System One Model" instead of a
chat-completion judge. `switchyard-libsy` stays I/O-free: the classifier
depends only on a new `TypeSafeProvider` port, and a new
`switchyard-typesafe-client` crate supplies the runner-owned HTTP
implementation, injected once per deployment via a `[type_safe_client]`
table. Fails open on a low-confidence, unresolved, or out-of-range verdict,
or a provider error. (#723)
- **`timeout_ms` on `[llm_clients.<name>]`** — one deadline covers all attempts,
retry delays, and the complete response, including stream reads. Unset leaves
the wait unbounded; `0` is rejected. A timeout returns `504` without trying another
Expand Down
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"crates/switchyard-skill-distillation",
"crates/switchyard-soak",
"crates/switchyard-translation",
"crates/switchyard-typesafe-client",
]

[workspace.package]
Expand Down Expand Up @@ -49,6 +50,7 @@ switchyard-protocol = { path = "crates/protocol", version = "0.3.0" }
switchyard-runner = { path = "crates/switchyard-runner", version = "0.3.0" }
switchyard-server = { path = "crates/switchyard-server", version = "0.3.0" }
switchyard-translation = { path = "crates/switchyard-translation", version = "0.3.0" }
switchyard-typesafe-client = { path = "crates/switchyard-typesafe-client", version = "0.3.0" }
strum_macros = "0.28"
thiserror = "2"
tokio = { version = "1", features = ["full"] }
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ Most use an LLM as a judge. All of them pick between an **efficient** model and
| Algorithm | How it decides | Route `type` | Benchmark |
|---|---|---|---|
| **[Capability](docs/routing_algorithms/llm_classifier_routing.md)** | The first request is judged by an LLM. | `llm_classifier` | 71.2% at $79.32 |
| **[TypeSafe Classifier](docs/routing_algorithms/type_safe_classifier_routing.md)** | Every request is judged by TypeSafe's Jev, a non-generative classifier — no chat-completion judge call. | `type_safe_classifier` | not yet benchmarked |
| **[Stage](docs/routing_algorithms/stage_router_routing.md)** | Tool responses are judged by pattern matching or an LLM. | `stage_router` | 72.7% at $68.19 |
| **[Capability + Stage](docs/routing_algorithms/composite_routing.md)** | Combines the two above. | `composite` | not yet benchmarked |
| **[Escalation](docs/routing_algorithms/escalation_router_routing.md)** | Starts efficient. Responses are judged by an LLM for issues, then escalated. | `llm_classifier` + `mode = "escalation"` | 75.7% at $85.00 |
Expand Down
1 change: 1 addition & 0 deletions crates/libsy/src/algorithms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod passthrough;
pub mod rand;
pub mod stage;
pub mod subagent;
pub mod type_safe_class;

pub mod util;

Expand Down
6 changes: 3 additions & 3 deletions crates/libsy/src/algorithms/llm_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl TaskClassifierVerdict {
/// Selects by reference and clones only what survives — a coding-agent
/// conversation carries every tool result, so cloning it whole to keep a window
/// would copy the transcript on each judged turn.
fn trim_messages(messages: &[Message], recent_turn_window: usize) -> Vec<Message> {
pub(crate) fn trim_messages(messages: &[Message], recent_turn_window: usize) -> Vec<Message> {
let is_instruction = |message: &Message| matches!(message.role, Role::System | Role::Developer);
let mut kept: Vec<&Message> = messages.iter().filter(|m| is_instruction(m)).collect();
let Some(task) = messages.iter().position(|m| m.role == Role::User) else {
Expand Down Expand Up @@ -149,7 +149,7 @@ fn window_start(tail: &[&Message], recent_turn_window: usize) -> usize {
}

/// Keeps the opening task and the latest user follow-up when they differ.
fn task_messages(messages: &[Message]) -> Vec<Message> {
pub(crate) fn task_messages(messages: &[Message]) -> Vec<Message> {
let mut user_messages = messages.iter().filter(|message| message.role == Role::User);
let Some(opening_task) = user_messages.next() else {
return Vec::new();
Expand Down Expand Up @@ -498,7 +498,7 @@ impl JudgePolicy for CustomPolicyRuntime {
}

/// Builds the affinity router a trigger calls for, if any.
fn affinity_router(
pub(crate) fn affinity_router(
trigger: ClassifyTrigger,
message_hash_fallback: bool,
) -> Option<Arc<AffinityRouter>> {
Expand Down
Loading