Skip to main content

Crate neuron_turn_kit

Crate neuron_turn_kit 

Source
Expand description

neuron-turn-kit

Planning and execution primitives for a single agent turn — focused on sequencing and concurrency only. These traits are intentionally narrow and do not bake in provider streaming, hooks, or operator concerns; those live at higher layers (e.g., operator implementations).

Contents:

  • Concurrency and ConcurrencyDecider — classify tool calls as Shared vs Exclusive
  • ToolExecutionPlanner and BarrierPlanner — sequence tool calls into batches
  • SteeringSource — optional source of mid-loop steering messages
  • BatchExecutor — run batches, with a simple sequential baseline executor

Example: planning with a barrier.

use neuron_turn_kit::{BarrierPlanner, Concurrency, ConcurrencyDecider, ToolExecutionPlanner};

struct SharedIfStartsWith;
impl ConcurrencyDecider for SharedIfStartsWith {
    fn concurrency(&self, tool_name: &str) -> Concurrency {
        if tool_name.starts_with("shared_") { Concurrency::Shared } else { Concurrency::Exclusive }
    }
}

let calls = vec![
    ("1".to_string(), "shared_a".to_string(), serde_json::json!({})),
    ("2".to_string(), "exclusive".to_string(), serde_json::json!({})),
    ("3".to_string(), "shared_b".to_string(), serde_json::json!({})),
];
let planner = BarrierPlanner;
let plan = planner.plan(&calls, &SharedIfStartsWith);
assert!(matches!(plan[0], neuron_turn_kit::BatchItem::Shared(_)));

Structs§

BarrierPlanner
Barrier planner: batches shared tools; flushes on exclusive.
SequentialBatchExecutor
Baseline sequential executor: executes all tool calls in order, without introducing any parallelism (Shared batches are executed one-by-one).

Enums§

BatchItem
Planned batches for a turn.
Concurrency
Concurrency hint for tool scheduling (strategy-defined).

Traits§

BatchExecutor
Contract for executing planned batches.
ConcurrencyDecider
Decide concurrency for a tool by name.
SteeringSource
Optional source of steering messages to inject mid-loop (provider-formatted).
ToolExecutionPlanner
Plan how to execute tool calls this turn (sequencing only).