error-handling-discipline
Skill6 starsChanged 4 months agoMITView on GitHub
Дисциплина ошибок: ловим ожидаемые исключения (LLMError/ToolError/TimeoutError), нет необработанных, пользователю — человеческое сообщение, stacktrace только в лог.
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/agents.mdcCursor rule
- architecture-disciplineSkill
- async-disciplineSkill
- automation-disciplineSkill
- debugging-disciplineSkill
- documentation-disciplineSkill
- git-disciplineSkill
- prompt-injection-defenseSkill
- pr-review-disciplineSkill
- pull-request-disciplineSkill
- skill-authoringSkill
- testing-disciplineSkill
The file
Files
Skill: error-handling-discipline
Правила обработки ошибок. Источник истины — _docs/instructions.md §5 и §6, _docs/architecture.md §2.
Когда использовать
- Пишешь или меняешь handler, tool, агентный цикл или сервис с внешним I/O.
- Добавляешь новый класс ошибок или новую внешнюю интеграцию.
- Формируешь сообщение пользователю при сбое.
Алгоритм
- Нет необработанных исключений (NFR-3). Каждый handler / tool / агентный цикл либо сам ловит ожидаемые (
LLMError,ToolError,asyncio.TimeoutError), либо полагается на глобальный error handler в Dispatcher. - Переиспользуй существующие иерархии, не плоди новые в обход:
app/services/llm.py:LLMError → LLMTimeout / LLMUnavailable / LLMBadResponse.app/tools/errors.py:ToolError → ToolNotFound / ArgsValidationError.
- Пользователю — человеческое сообщение, без stacktrace и внутренних деталей. Текст — по §1 (русский).
- Stacktrace — только в лог:
logger.exception(...)илиlogger.error(..., exc_info=True). Чувствительные данные в лог не пишем (§6). - Отказоустойчивость по слоям. Таймаут LLM, сетевой сбой, недоступность Ollama, битый JSON, упавший tool, превышение лимита шагов — каждый ловится и превращается в понятное сообщение + запись в лог (
_docs/architecture.md§2). - Деградация, а не падение. Где это предусмотрено (авто-подгрузка архива,
Planner/Critic) —WARNINGи продолжение с последним доступным результатом, а не исключение наружу.
Чего избегать
- Голого
except Exception: passи проглоченных ошибок без лога. - Stacktrace и внутренних путей в сообщении пользователю (см.
prompt-injection-defense). - Новых ad-hoc классов ошибок вместо существующих иерархий.
- Необработанного I/O, способного уронить агентный цикл.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

