Playground
Inspect token timelines and intervention behavior on live shared requests.
Runtime Intervention Engine
Open-source modified inference engine and SDK for token-level interventions during runtime.
Inspect token timelines and intervention behavior on live shared requests.
Implement Python mods, action builders, and event-scoped control patterns.
Open-source engine + SDK for practical runtime intervention workflows.
Findings from token injection experiments across reasoning and non-reasoning models.
Use the @mod decorator to respond to runtime events with an event-scoped ActionBuilder.
12345@moddef runtime_control(event, actions: ActionBuilder, tokenizer):if isinstance(event, (Prefilled, ForwardPass, Added)):return actions.noop()return actions.noop()
Rewrite or replace prompt context before generation begins.
12345678@moddef patch_prefill(event, actions: ActionBuilder, tokenizer):if isinstance(event, Prefilled):replacement = "System: answer concisely\n" + event.prefilled_textreturn actions.adjust_prefill(tokenizer.encode(replacement))return actions.noop()
Mask or reweight token probabilities during forward pass for constrained outputs.
12345678@moddef logits_guard(event, actions: ActionBuilder, tokenizer):if isinstance(event, ForwardPass):logits = event.logits.clone()blocked = tokenizer.encode("unsafe")[0]logits[blocked] = -1e9return actions.adjusted_logits(logits)return actions.noop()
Inject forced continuations, or rewind and replace problematic spans at runtime.
123456@moddef revise_suffix(event, actions: ActionBuilder, tokenizer):if isinstance(event, Added) and event.step > 30:replacement = tokenizer.encode("Let's restate clearly:")return actions.backtrack(n=8, replacement=replacement)return actions.noop()
Emit structured tool call payloads from mod logic when user or context conditions match.
12345678@moddef route_tools(event, actions: ActionBuilder, tokenizer):if isinstance(event, Prefilled):return actions.tool_calls([{"name": "search_docs","arguments": {"query": "token injection"}}])return actions.noop()
Run constrained generation flows with strategy constructors and completion controls.
123456789101112runtime_tool_question = FlowQuestion(name="runtime_tool_router",prompt="Should I call a runtime tool?",responses=["yes", "no"],erase_mode="all",)@moddef runtime_flow(event, actions: ActionBuilder, tokenizer):if isinstance(event, (Prefilled, ForwardPass, Added)):return ENGINE.handle_event(event, actions, tokenizer)return actions.noop()