Skip to content

fix: subagent tool call argument display issue#171

Merged
stdrc merged 1 commit intomainfrom
rc/fix-subagent-tool-call-arg
Nov 6, 2025
Merged

fix: subagent tool call argument display issue#171
stdrc merged 1 commit intomainfrom
rc/fix-subagent-tool-call-arg

Conversation

@stdrc
Copy link
Contributor

@stdrc stdrc commented Nov 6, 2025

No description provided.

Signed-off-by: Richard Chien <stdrc@outlook.com>
Copilot AI review requested due to automatic review settings November 6, 2025 17:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_argument to accept both string and Lexer inputs
  • Renamed the internal variable from subtitle to key_argument for 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
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
@stdrc stdrc merged commit b7c1064 into main Nov 6, 2025
10 checks passed
@stdrc stdrc deleted the rc/fix-subagent-tool-call-arg branch November 6, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants