Repository navigation
fix(ai): keep the work log when a write tool ran before an unclassified error (Refs #182) - #247
Merged
Merged
Conversation
|
🔁 PR closed. Stage bot switched back to |
2 tasks done
alex-mextner
force-pushed
the
fix-agent-worklog-unclassified
branch
from
November 7, 2026 09:47
71f9851 to
4c1123b
Compare
…ed error (Refs #182) failRun deleted the streamed work log on any unclassified (non-AI) error. When a write tool (add_expense, set_budget) had already run, the user lost the only record of what was done, re-added the expense and got a duplicate. Now: writeToolRan keeps the log, renders the failure message under it and throws AgentError (message already sent — the caller sends no duplicate); AgentError carries the original error as cause for the logs.
alex-mextner
force-pushed
the
fix-agent-worklog-unclassified
branch
from
November 7, 2026 09:59
4c1123b to
93e7a36
Compare
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.
Что было
failRunвsrc/services/ai/agent.tsна любой неклассифицированной ошибке (баг/не-AI сбой посреди диалога) вызывалwriter.deleteSentMessage()— удалял стримящийся «журнал работы» бота. Если до ошибки уже отработал write-инструмент (add_expense/set_budget), пользователь терял единственную запись о том, что расход записан, добавлял его повторно — и получал дубль (issue #182).Фикс
failRun: приwriteToolRanжурнал сохраняется, сообщение об ошибке рендерится под ним (writer.fail(UNCLASSIFIED_FAILURE_MESSAGE)), наружу летитAgentError— егоuserMessageуже на экране, вызывающий (ask.ts) не шлёт дубль.AgentErrorтеперь принимаетcause— оригинальная ошибка сохраняется для логов, а не маскируется.UNCLASSIFIED_FAILURE_MESSAGE(agent.ts + ask.ts — один источник).Без write-инструментов поведение прежнее: плейсхолдер удаляется, оригинальная ошибка пробрасывается.
Тесты
agent.errors.test.ts: «a write tool, then an unclassified non-AI error: the work log stays, failure under it» — AgentError брошен,deleteMessageне вызывался, журнал «Записываю расход: 5 EUR, Еда» виден, под ним текст ошибки (red-verified на старом коде).ask.history.test.ts: мок обновлён под экспорт константы.Gates:
server-run -- bun run test— 253 файла / 6071 тест, 0 fail; type-check ✅; lint ✅. Машинное ревью: чисто, в т.ч. регрессионные ветки (no-write-tools, classified AI errors).Refs #182