{"slug": "stop-letting-llms-hallucinate-dates-a-tool-for-ai-agents", "title": "Stop letting LLMs hallucinate dates — a tool for AI agents", "summary": "A developer has released `whenis`, an open-source tool that moves date interpretation out of LLMs and into deterministic parsing, addressing the common problem of AI agents hallucinating weekday-to-date mappings and range errors. The tool uses a four-layer pipeline with independently testable components, supporting multiple locales and plugins for domain-specific date handling. Currently shipping with Ukrainian and English locales plus a booking plugin, `whenis` is available on GitHub under an MIT license.", "body_md": "If you're building an AI agent that touches dates — booking flows, scheduling bots, \"remind me on Friday\" assistants — you've probably noticed:\n\n**LLMs are terrible at dates.**\n\nThey hallucinate weekday-to-date mappings. They fencepost-error ranges. They forget what \"next Friday\" means in Ukrainian vs English. Asking the model to \"be careful\" doesn't fix it — what fixes it is moving date interpretation out of the model and into a deterministic tool.\n\nThat's what `whenis`\n\nis.\n\nDefine a `resolveDate(expression, reference)`\n\ntool that calls `whenis`\n\n. Let the model invoke it instead of guessing.\n\n``` js\nimport { createParser } from '@whenis/core';\nimport { uk } from '@whenis/locale-uk';\nimport { booking } from '@whenis/booking';\n\nconst parser = createParser({\n  locales: [uk],\n  plugins: [booking],\n  options: { preferFuture: true },\n});\n\nconst ref = new Date('2026-05-28');\n\nparser.parse(\"наступної п'ятниці\", { reference: ref });\n// → { type: 'date', date: '2026-06-05', confidence: 1 }\n\nparser.parse('з 5 по 10 червня', { reference: ref });\n// → { type: 'range', start: '2026-06-05', end: '2026-06-11', nights: 6 }\n\nparser.parse('після свят', { reference: ref });\n// → { type: 'fuzzy', reason: 'holiday_ref',\n//     metadata: { suggest_next_month: true } }\n```\n\nEnglish works the same way:\n\n``` js\nimport { en } from '@whenis/locale-en';\n\nconst parser = createParser({ locales: [en], options: { preferFuture: true } });\n\nparser.parse('next Friday', { reference: new Date('2026-05-28') });\n// → { type: 'date', date: '2026-06-05', confidence: 1 }\n```\n\n`@whenis/booking`\n\n, not the core. Build your own plugin for your domain.Duckling-style 4-layer pipeline:\n\n```\ninput\n  ↓\npreprocess  →  tokenize + tag  →  rule engine  →  resolver\n                                                          ↓\n                                                  ParseResult\n```\n\nEach layer is independently testable. The rule engine is iterative and compositional — rules match tokens **or** previously emitted IR nodes, looping until fixpoint.\n\nThe output is a `ParseResult`\n\nwith `matches[].candidates[]`\n\n— each candidate has a `type`\n\n, ISO dates, optional `nights`\n\n, a `confidence`\n\nscore, a human-readable `reason`\n\n, and a `metadata`\n\nbag plugins can extend.\n\nESM + CJS dual builds, strict TypeScript, Node ≥18, zero DOM dependencies.\n\n```\nnpm i @whenis/core @whenis/locale-uk @whenis/booking\n# or just core + the locale you need\nnpm i @whenis/core @whenis/locale-en\n```\n\n`@whenis/core`\n\nis a peer dependency of every locale and plugin — install it explicitly so you control the version in one place.\n\nv0.1 ships UA + EN locales and the booking plugin. v0.2 backlog: ISO passthrough rule, DD.MM numeric forms, Ukrainian word-numerals, `до кінця тижня/місяця`\n\nwindow, more English coverage. Issues and PRs welcome.\n\nRepo: [github.com/norens/whenis](https://github.com/norens/whenis) · MIT", "url": "https://wpnews.pro/news/stop-letting-llms-hallucinate-dates-a-tool-for-ai-agents", "canonical_source": "https://dev.to/nazarf/stop-letting-llms-hallucinate-dates-a-tool-for-ai-agents-1jjj", "published_at": "2026-05-28 12:52:11+00:00", "updated_at": "2026-05-28 13:23:07.769501+00:00", "lang": "en", "topics": ["large-language-models", "ai-agents", "natural-language-processing", "ai-tools", "ai-products"], "entities": ["whenis", "whenis/core", "whenis/locale-uk", "whenis/locale-en", "whenis/booking"], "alternates": {"html": "https://wpnews.pro/news/stop-letting-llms-hallucinate-dates-a-tool-for-ai-agents", "markdown": "https://wpnews.pro/news/stop-letting-llms-hallucinate-dates-a-tool-for-ai-agents.md", "text": "https://wpnews.pro/news/stop-letting-llms-hallucinate-dates-a-tool-for-ai-agents.txt", "jsonld": "https://wpnews.pro/news/stop-letting-llms-hallucinate-dates-a-tool-for-ai-agents.jsonld"}}