agentscope-gemini-usage-fix
БесплатноБез исполняемых скриптовНе проверенWork around a Gemini usage normalization bug in AgentScope where cached_content_token_count=None causes Usage validation to fail. Use this whenever the user…
от trend0522354 установки в других каталогахОб этом скилле
AgentScope Gemini Usage Fix
This skill documents a known bug and a runtime workaround for GeminiChatModel usage extraction.
Bug
GeminiChatModel._extract_usage uses getattr(..., "cached_content_token_count", 0), which returns None when the attribute exists but is None. ChatUsage validates cache_input_tokens as int, so None raises a pydantic ValidationError.
Workaround
Apply this patch before using Gemini models:
from agentscope.model._gemini._model import GeminiChatModel
_original = GeminiChatModel._extract_usage
def _patched_extract_usage(self, usage_metadata, start_datetime):
if not usage_metadata:
return None
usage = _original(self, usage_metadata, start_datetime)
if usage and getattr(usage, "cache_input_tokens", None) is None:
usage.cache_input_tokens = 0
return usage
GeminiChatModel._extract_usage = _patched_extract_usage
Upstream Fix
The upstream fix is a one-line change:
cache_input_tokens=getattr(
usage_metadata,
"cached_content_token_count",
0,
) or 0,
Reference: https://github.com/agentscope-ai/agentscope/issues/3077
Установить agentscope-gemini-usage-fix в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл agentscope-gemini-usage-fix?
Work around a Gemini usage normalization bug in AgentScope where cached_content_token_count=None causes Usage validation to fail. Use this whenever the user uses GeminiChatModel and sees ValidationError on cache_input_tokens.
Как установить скилл agentscope-gemini-usage-fix?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл agentscope-gemini-usage-fix запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic