Skip to main content Module protocol Copy item path Source InstructionTemplate A terse instruction code and its human-readable expansion. ToolCallRecord Recorded metrics for a single MCP tool invocation. CrpMode Context Reduction Protocol mode controlling output verbosity. append_savings Appends a savings footer to output with a newline separator, but only if the footer is non-empty. detect_project_root Finds the outermost project root by walking up from file_path.
For monorepos with nested .git dirs (e.g. mono/backend/.git + mono/frontend/.git),
returns the outermost ancestor containing .git, a workspace marker, or a known
monorepo config file — so the whole monorepo is treated as one project. detect_project_root_or_cwd Returns the project root for file_path, falling back to cwd if none found.
Logs a warning when the fallback is a broad directory (home, root). encode_instructions Encode an instruction suffix using short codes with budget hints.
Response budget is dynamic based on task complexity to shape LLM output length. encode_instructions_with_snr Encode instructions with SNR metric for context quality awareness. format_savings Formats a token savings summary like [42 tok saved (30%)]. instruction_decoder_block Generates the INSTRUCTION CODES block for agent system prompts. savings_footer_visible Returns true if savings footers should be shown based on config + transport context. set_mcp_context Mark the current process as serving MCP tool calls (suppresses savings footers in auto mode). shorten_path Returns the file name component of a path for compact display.