Fix: Parse <tool_call> JSON for Kimi K2 + Add Kimi CLI OAuth support#3175
Closed
AIandI0x1 wants to merge 2 commits into
Closed
Fix: Parse <tool_call> JSON for Kimi K2 + Add Kimi CLI OAuth support#3175AIandI0x1 wants to merge 2 commits into
AIandI0x1 wants to merge 2 commits into
Conversation
Models like Kimi K2 output tool calls embedded in content as:
<tool_call>{"name": "tool_name", "arguments": {...}}</tool_call>
This was being displayed raw instead of being parsed and executed.
Changes:
- Add agent/response_adapters.py with adapt_hermes_tool_call_response() to parse
Hermes-style <tool_call> JSON format
- Apply adapter in main agent loop when <tool_call> detected in content
- Reuses existing _parse_hermes_json_tool_calls() logic
Fix is model-agnostic: works for any model outputting this format.
Fixes issue where tool calls from kimi-coding provider were not executed.
Add support for using Kimi CLI OAuth credentials to authenticate with the kimi-coding provider (api.kimi.com). This allows users who have authenticated with the official Kimi CLI to use those same credentials in hermes-agent without separate API keys. Changes: - Add _read_kimi_cli_oauth_credentials() to read ~/.kimi/credentials/kimi-code.json - Add _get_kimi_cli_headers() to generate proper headers for OAuth requests - Add _get_kimi_cli_device_id() helper - Update _resolve_api_key_provider_secret() to check for Kimi CLI OAuth first - Update resolve_api_key_provider_credentials() to return default_headers - Update AIAgent to use OAuth headers when available Non-breaking: Falls back to simple User-Agent header if OAuth not available.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for Kimi K2 models and improves authentication with Kimi CLI OAuth.
Changes
1. Fix Tool Call Parsing (
agent/response_adapters.py)Models like Kimi K2 output tool calls embedded in content:
Previously these were displayed raw to users instead of being executed. Now they're properly parsed and executed.
Changes:
agent/response_adapters.pywithadapt_hermes_tool_call_response()function_parse_hermes_json_tool_calls()logic<tool_call>detected in content2. Add Kimi CLI OAuth Support (
hermes_cli/auth.py,agent/auxiliary_client.py)Users who have authenticated with the official Kimi CLI can now use those same credentials without separate API keys.
Changes:
_read_kimi_cli_oauth_credentials()to read~/.kimi/credentials/kimi-code.json_get_kimi_cli_headers()to generate proper headers for OAuth requests_get_kimi_cli_device_id()helper_resolve_api_key_provider_secret()to check for Kimi CLI OAuth firstresolve_api_key_provider_credentials()to returndefault_headersAIAgentto use OAuth headers when availableTesting
kimi-k2.5modelBackward Compatibility