mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 23:47:54 +08:00
cli/display: read past the approval line when rendering a detail
The line is for the model, and the human already saw the prompt. A detail that parses the result (write_file's char count) must not see a header in front of it; the verbose `[tool ok]` view keeps the whole text.
This commit is contained in:
@@ -1069,9 +1069,21 @@ def _pretty_line_for(name: str) -> PrettyLine | None:
|
|||||||
return _PRETTY_LINES.get(name) or _mcp_line(name)
|
return _PRETTY_LINES.get(name) or _mcp_line(name)
|
||||||
|
|
||||||
|
|
||||||
|
_APPROVAL_LINE = re.compile(r"\A\[approval\] [^\n]*\n")
|
||||||
|
|
||||||
|
|
||||||
|
def _without_approval_line(result: str) -> str:
|
||||||
|
"""The tool's own text, without the leading ``[approval]`` line.
|
||||||
|
|
||||||
|
That line is for the model (the human already saw the prompt); a pretty
|
||||||
|
detail reads the result it knows, not a header in front of it.
|
||||||
|
"""
|
||||||
|
return _APPROVAL_LINE.sub("", result, count=1)
|
||||||
|
|
||||||
|
|
||||||
def _pretty_parts(line: PrettyLine, args_json: str, result: str) -> tuple[str, str]:
|
def _pretty_parts(line: PrettyLine, args_json: str, result: str) -> tuple[str, str]:
|
||||||
"""Prefix + detail for a resolved pretty tool call."""
|
"""Prefix + detail for a resolved pretty tool call."""
|
||||||
return line.prefix(args_json), line.detail(args_json, result)
|
return line.prefix(args_json), line.detail(args_json, _without_approval_line(result))
|
||||||
|
|
||||||
|
|
||||||
def _echo_stream(text: str) -> None:
|
def _echo_stream(text: str) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user