Expand description
Session and turn loop boundaries (P2 PR2–PR4).
Session and related state live here. The live Engine / turn_loop
implementation is in zagens-core; the sidecar provides host adapters.
PR3: StartTurnParams + TurnEnginePort — RuntimeThreadManager::start_turn
validates and delegates through core before sending Op::SendMessage.
Re-exports§
pub use crate::session::Session;pub use crate::session::SessionUsage;pub use crate::turn::TurnContext;pub use crate::turn::TurnLoopMode;pub use crate::turn::TurnOutcomeStatus;pub use approval::ApprovalDecision;pub use approval::ApprovalResult;pub use approval::UserInputDecision;pub use approval::await_tool_approval;pub use approval::recv_user_input_for_tool;pub use context::COMPACTION_SUMMARY_MARKER;pub use context::MAX_CONTEXT_RECOVERY_ATTEMPTS;pub use context::MIN_RECENT_MESSAGES_TO_KEEP;pub use context::TURN_MAX_OUTPUT_TOKENS;pub use context::compact_tool_result_for_context;pub use context::context_input_budget;pub use context::count_oldest_messages_to_drain;pub use context::effective_max_output_tokens;pub use context::estimate_input_tokens_conservative;pub use context::extract_compaction_summary_prompt;pub use context::is_context_length_error_message;pub use context::summarize_text;pub use context::turn_response_headroom_tokens;pub use context_snapshot::ThreadContextSnapshot;pub use dispatch::ToolParallelPlanFlags;pub use dispatch::caller_allowed_for_tool;pub use dispatch::caller_type_for_tool_use;pub use dispatch::final_tool_input;pub use dispatch::format_tool_error;pub use dispatch::is_mcp_tool_name;pub use dispatch::mcp_tool_approval_description;pub use dispatch::mcp_tool_is_parallel_safe;pub use dispatch::mcp_tool_is_read_only;pub use dispatch::parse_parallel_tool_calls;pub use dispatch::parse_tool_input_json;pub use dispatch::should_force_update_plan_first;pub use dispatch::should_parallelize_tool_batch;pub use dispatch::should_stop_after_plan_tool;pub use handle::EngineHandle;pub use host_bundle::EngineHostBundle;pub use hosts::LspHost;pub use hosts::McpHost;pub use hosts::SandboxHost;pub use hosts::SeamError;pub use hosts::SeamHost;pub use hosts::ShellHost;pub use hosts::SubAgentHost;pub use hosts::TopicMemoryHost;pub use hosts::WorkshopHost;pub use loop_guard::AttemptDecision;pub use loop_guard::LoopGuard;pub use loop_guard::OutcomeDecision;pub use lsp_edit_paths::edited_paths_for_tool;pub use lsp_edit_paths::parse_patch_paths;pub use op::Op;pub use runtime::Engine;pub use scratchpad_state::ScratchpadStepState;pub use start_turn::StartTurnParams;pub use streaming::ContentBlockKind;pub use streaming::FAKE_WRAPPER_NOTICE;pub use streaming::MAX_STREAM_ERRORS_BEFORE_FAIL;pub use streaming::MAX_TRANSPARENT_STREAM_RETRIES;pub use streaming::STREAM_CHUNK_TIMEOUT_SECS;pub use streaming::STREAM_MAX_CONTENT_BYTES;pub use streaming::STREAM_MAX_DURATION_SECS;pub use streaming::TOOL_CALL_END_MARKERS;pub use streaming::TOOL_CALL_START_MARKERS;pub use streaming::ToolUseState;pub use streaming::contains_fake_tool_wrapper;pub use streaming::filter_tool_call_delta;pub use streaming::should_transparently_retry_stream;pub use subagent_port::SubAgentSpawnPort;Deprecated pub use subagent_port::SubAgentSpawnError;pub use subagent_port::SubAgentSpawnOutcome;pub use tool_bridge::function_call_to_tool_error;pub use tool_bridge::tool_call_input;pub use tool_bridge::tool_name_is_mutating;pub use tool_bridge::tool_output_to_result;pub use tool_bridge::tool_result_to_output;pub use tool_bridge::value_to_tool_call;pub use tool_catalog::CODE_EXECUTION_TOOL_NAME;pub use tool_catalog::MULTI_TOOL_PARALLEL_NAME;pub use tool_catalog::REQUEST_USER_INPUT_NAME;pub use tool_catalog::TOOL_SEARCH_BM25_NAME;pub use tool_catalog::active_tools_for_step;pub use tool_catalog::apply_mcp_tool_deferral;pub use tool_catalog::apply_native_tool_deferral;pub use tool_catalog::build_model_tool_catalog;pub use tool_catalog::ensure_advanced_tooling;pub use tool_catalog::execute_tool_search;pub use tool_catalog::initial_active_tools;pub use tool_catalog::is_tool_search_tool;pub use tool_catalog::maybe_activate_requested_deferred_tool;pub use tool_catalog::missing_tool_error_message;pub use tool_catalog::should_default_defer_tool;pub use tool_progress::emit_tool_audit;pub use tool_progress::tool_progress_opening_line;pub use tool_progress::tool_progress_phase_line;pub use turn_loop::McpPoolPort;pub use turn_loop::ToolExecOutcome;pub use turn_loop::ToolExecutionPlan;pub use turn_loop::ToolPlanApprovalMeta;pub use turn_loop::TurnLoopConfigView;pub use turn_loop::TurnLoopControl;pub use turn_loop::TurnLoopHost;pub use turn_loop::TurnLoopStreamingPhaseOutcome;pub use turn_loop::TurnLoopToolExec;pub use turn_loop::TurnLoopToolExecutor;pub use turn_loop::TurnLoopToolPhaseOutcome;pub use turn_loop::TurnLoopToolRegistry;pub use turn_loop::build_edit_file_approval_desc;pub use turn_loop::handle_deepseek_turn;pub use turn_loop::messages_with_turn_metadata;pub use turn_loop::resolve_auto_effort;
Modules§
- approval
- Tool-approval and user-input handshake for the agent loop (P2 PR4 →
zagens-core). - config
- Engine configuration — lean subset that depends only on core types
(M2 strangler step of the
Enginestruct →zagens-coremigration). - context
- Context budgeting and prompt-shaping helpers for the engine (P2 PR4).
- context_
snapshot - Thread-level context usage snapshot — pure data type (M1 →
zagens-core). - dispatch
- Tool-input parsing and batch policy helpers (P2 PR4).
- handle
- Engine handle — outbound channel set used by the UI/runtime to drive the
engine (M1 →
zagens-core). - host_
bundle - Host bundle for
super::runtime::Engine::with_hosts(M7). - hosts
- Subsystem host traits — the engine boundary for tui-owned subsystems.
- loop_
guard - Pure-data guardrails for repeated tool-call loops (P2 PR4 →
zagens-core). - lsp_
edit_ paths - Pure helpers for post-edit LSP path extraction (P2 tool_execution portization).
- op
- Operations submitted by the UI/runtime layer to the engine (M1 →
zagens-core). - op_loop
- Core engine event loop (
Opdispatch). - platform_
ext - Platform extension port for tui-specific op dispatch (M8).
- runtime
- Core
Enginestruct (M7 strangler step). - runtime_
new - Engine construction (
Engine::with_hosts, M7). - scratchpad_
state - Per-step scratchpad nudge state (B3/B4/B3b/C0/C1 audit scratchpad engine hooks).
- start_
turn - Normalized start-turn payload (P2 PR3).
- streaming
- Streaming response state and guardrails (P2 PR4 →
zagens-core). - subagent_
port - Sub-agent spawn outcome / error types (P2 tool_execution portization).
- tool_
bridge ToolCall↔ registry/ToolResultconversions forEngineToolDispatch(P2 PR4).- tool_
catalog - Deferred tool catalog policy and built-in tool-search helpers (P2 PR4).
- tool_
parser - Legacy parser for text-based tool calls from DeepSeek models.
- tool_
progress - Tool progress copy and optional JSONL audit logging (P2 PR4 →
zagens-core). - turn_
loop - Turn loop (P2 PR4/PR6):
handle_deepseek_turn, streaming + tool planning/outcomes in core; tool execution L2 in tui (tool_plans_exec).
Traits§
- Engine
Tool Dispatch - Minimal tool surface required by
Engine/turn_loop. - Turn
Engine Port - Minimal surface
RuntimeThreadManagerneeds to drive a turn.