render_tool_description#
Build typed tools from annotations and docstrings. See the guide.
- zett_agent.tools.base.render_tool_description(tool, *, snippet=True, guidelines=True, returns=False, base=None)[源代码]#
Return a tool description that carries its snippet and guidelines.
Some endpoints show the model only a tool's
description, and a deferred tool reaches the model through tool search with no system prompt beside it. Folding the guidance into the description keeps it next to the tool in both cases.The result keeps the guidance on one line of plain prose: no section headings, no bullets, and no line breaks. Snippet lines follow the description as call shapes after
You can call it as, with every line of a multi-line snippet listed and joined byor, and each guideline follows as a sentence, all separated by spaces. A guideline gets a full stop unless it already ends with sentence punctuation; text ending in a CJK ideograph or kana gets。instead of.. Whenreturnsis on, one more sentence says what the tool returns as JSON Schema, and the prose from itsReturnssection ends the description, after the guidelines. Like the schema sentence, that prose belongs to the snippet part, sosnippet=Falseleaves it out. Whenbasealready spans lines, as a tool-search catalog does, the guidance starts on its own line instead of continuing the base's last one, and the base keeps its formatting. The result is the plain description when the tool has nothing to add, so it is safe to call for every tool.- 参数:
tool (AgentTool) -- Tool whose metadata is rendered.
snippet (bool) -- Include the tool's snippet when it has one.
guidelines (bool) -- Include the tool's guidelines when it has any.
returns (bool) -- Add one sentence saying what the tool returns, after the snippet, and its docstring
Returnsprose at the end of the description.base (str | None) -- Text to put before the guidance, instead of
tool.description. Extensions that each add to a request's descriptions pass the text they received, so one does not overwrite what another appended.
- 返回类型:
str
示例
Render everything the model should know in one string:
text = render_tool_description(read_file)