fix: subagent tool call argument display issue#171
Conversation
Signed-off-by: Richard Chien <stdrc@outlook.com>
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the extract_key_argument function to accept either a string or a streamingjson.Lexer object, improving code maintainability and simplifying call sites.
- Refactored
extract_key_argumentto accept both string and Lexer inputs - Renamed the internal variable from
subtitletokey_argumentfor better clarity - Improved UI message pluralization for tool call counts
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/kimi_cli/tools/init.py | Refactored extract_key_argument to accept both string and Lexer objects; renamed variable from subtitle to key_argument |
| src/kimi_cli/ui/shell/visualize.py | Simplified call to extract_key_argument by passing string directly instead of creating a Lexer; improved pluralization of "tool call" message |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| content: list[str] = cast(list[str], json_content.json_content) # pyright: ignore[reportUnknownMemberType] | ||
| key_argument = "".join(content) | ||
| else: | ||
| key_argument = json_content |
There was a problem hiding this comment.
When json_content is a string in the default case, it's used directly as key_argument. However, this bypasses the JSON parsing logic that was applied to all other cases. If json_content is a valid JSON string, this will result in returning the raw JSON string instead of extracting a meaningful value from it. Consider parsing json_content as JSON first, similar to lines 23-27.
| key_argument = json_content | |
| # Try to parse as JSON, similar to above | |
| try: | |
| parsed = json.loads(json_content) | |
| if isinstance(parsed, dict): | |
| key_argument = str(parsed) | |
| elif isinstance(parsed, list): | |
| key_argument = ", ".join(str(item) for item in parsed) | |
| else: | |
| key_argument = str(parsed) | |
| except json.JSONDecodeError: | |
| key_argument = json_content |
No description provided.