Skip to main content

Module prompt_catalog

Module prompt_catalog 

Source
Expand description

System-prompt catalog of activatable tools (progressive disclosure).

In progressive mode the model starts with a small core of tools and has to know that more exist before it will search for or activate them. This module renders a compact, one-line-per-tool listing of every activatable tool outside the session core, which the runtime appends to the system prompt.

Prompt-cache contract: the text is a pure function of the catalog at the moment it is rendered (sorted by tool id, no generation numbers, no “already active” markers), and the runtime freezes it per session, so an activation or a late tool registration never changes the cached prefix.

Descriptions come from third parties (MCP servers, extensions): they are sanitized (no control characters or newlines, provider tag dropped, first sentence only, clamped) and framed as data.

Constants§

MAX_LISTED
Maximum tools listed individually; the rest are counted per source.
MAX_LISTED_BYTES
Maximum bytes of listed lines; the rest are counted per source.
SUMMARY_MAX_CHARS
Maximum characters kept from one tool’s summary.

Functions§

render
Render the catalog of activatable tools that are not in core, or None when there are none. activatable decides trust (the same check activate_tools applies); core holds the session core’s tool ids.
sanitize_summary
One clean line from a third-party description: control characters and newlines removed, whitespace collapsed, a leading [MCP:server]-style tag dropped, first sentence only, at most SUMMARY_MAX_CHARS characters.