-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: optionally show tool calls in CLI #3097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
I don't think we need to give an option, but the experience should be good. |
pydantic_ai_slim/pydantic_ai/_cli.py
Outdated
config_dir: Path | None = None, | ||
deps: AgentDepsT = None, | ||
message_history: list[ModelMessage] | None = None, | ||
show_tool_calls: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with @Kludex -- we can always show tool calls, and remove the flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok nice, just wasn't sure if some people maybe don't want them. I removed the option.
pydantic_ai_slim/pydantic_ai/_cli.py
Outdated
) | ||
elif isinstance(event, FunctionToolResultEvent): | ||
console.print( | ||
Markdown(f'[Tool] {event.result.tool_name!r} returned => {event.result.content}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you show a screenshot of what this looks like please?
I wonder if we can get some prettier styling from Rich as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, we probably can. I updated it today a bit, so the status update works correctly and shows when a model is called and when tools are exectuted. Currently it looks like this:
I could involve colors or rich Panels. If you have any preference, please tell me :)
I wasn't sure how to manage long tool results (e.g. whole document parts from retrieval tools) or long tool calls. I just truncated it for now, because it feels cluttered otherwise. On the other hand, this feature (.to_cli()) feels more like just a debugging tool for dev's, which might prefer to just have all the output instead of nice visuals (assuming they are still readable).
I think other cli's manages it by having a keybind for collapsing and expaning long content sections, so that might be an option at some point, although more complex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it looks a bit too much like logging now, rather than a UI. People definitely use this as a full blown LLM chat client, not just a debugging tool. So having this optional is good, but I'd also want a way to have it display more like in chat apps, showing that the LLM is doing work more than dumping the entire payload. Perhaps we can start with a verbosity flag, and then add keybinding at some future point?
Add the option to print tool calls and their results in the
.to_cli()
method. Would really help debugging.