feat(agent): adopt AI SDK v7 — crash safety, context pruning, HITL approvals (#3362)

* docs(adr): propose agent AI SDK v7 adoption plan

* fix(ai): bind analyzeResume through aiService in service test

The test destructured analyzeResume as a named export that does not exist; main was red.

* test(agent): keep pure ai helpers real via spread-actual mock factory

* feat(agent): add run guards, patch version guard, run wall-clock timeout

* feat(agent): validate UI messages at the send boundary

* feat(agent): crash-safe draft-row persistence and server-side cancellation

* feat(agent): reap stale run claims at boot, on send, and on thread open

* feat(agent): fresh-document patch output and tiered context pruning

* feat(ai): shared agent tool contracts and message metadata schema

* feat(agent): add per-thread review-patches setting with update endpoint

* feat(agent): gate resume patches behind hmac-signed tool approval

* feat(agent): merge question answers and approval decisions before run claim

* feat(agent): approval ui with composed auto-send and fixture-driven tests

* feat(agent): usage metadata, tool activity cards, smoother streaming

* feat(agent): tool-call repair, input examples, structured step logging

* chore(i18n): translate new agent workspace strings across all locales

* fix(agent): gate stale-run draft cancellation on winning the claim clear

Snapshot streaming drafts before the conditional clear and skip the flip entirely when another reaper or a replacement run already cleared the claim. Also address review nits in eleven locale catalogs.

* fix(agent): flip reaped drafts only when their snapshotted state is unchanged

* fix(agent): address review findings across run lifecycle, context budget, and approval flow

- bind patches to the revision the model read via signed baseUpdatedAt
- claim the run before consuming a continuation; recorded-but-unexecuted approvals retry as pending continuations
- keep run ownership on stop() until cancellation persists; preserve the claim for the reaper when final persistence fails
- estimate tokens without serializing binary attachments (tokenx) and enforce the budget by dropping oldest whole turns
- mark crash-recovered patch results as snapshot boundaries; strip /data prefixes at execution time
- retry failed continuations without regenerate; mount a single AgentChat; disable response controls on read-only threads; freeze review toggle during runs (client+server)
- accumulate usage across continuations and match the SDK's nested usage shape; label-form token strings; reorderable source label; accessible note field; state-neutral web-search label

* chore(i18n): translate revised agent strings across all locales

* fix(agent): harden baseUpdatedAt validation and address review follow-ups

- bundle tokenx in the server runtime dependencies (e2e boot failure)
- strict ISO schema for baseUpdatedAt plus loud executor rejection of unparseable values
- it-IT source label consistency (Fonte)
- prove penultimate-turn retention in the context pruning test

* chore(deps): exempt tokenx from knip for the externalized server bundle
This commit is contained in:
Amruth Pillai
2026-08-20 08:06:53 +02:00
committed by GitHub
parent dbbab6fd76
commit c8081ac2fe
95 changed files with 14919 additions and 497 deletions
+39
View File
@@ -267,6 +267,9 @@ importers:
sharp:
specifier: ^0.35.3
version: 0.35.3(@types/node@26.2.0)
tokenx:
specifier: ^2.1.0
version: 2.1.0
ts-pattern:
specifier: ^5.9.0
version: 5.9.0
@@ -560,6 +563,9 @@ importers:
'@rolldown/plugin-babel':
specifier: ^0.2.3
version: 0.2.3(@babel/core@8.0.1)(@babel/runtime@7.29.7)(rolldown@1.2.4)(vite@8.2.1(@types/node@26.2.0)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.12)(yaml@2.9.0))
'@shadcn/helpers':
specifier: ^0.2.0
version: 0.2.0(ai@7.0.66(zod@4.4.3))
'@tanstack/devtools-vite':
specifier: ^0.8.3
version: 0.8.3(@emnapi/core@1.11.2)(@emnapi/runtime@1.11.3)(vite@8.2.1(@types/node@26.2.0)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.12)(yaml@2.9.0))
@@ -636,6 +642,9 @@ importers:
'@typescript/native-preview':
specifier: 7.0.0-dev.20260707.2
version: 7.0.0-dev.20260707.2
ai:
specifier: ^7.0.66
version: 7.0.66(zod@4.4.3)
typescript:
specifier: ^7.0.2
version: 7.0.2
@@ -738,6 +747,9 @@ importers:
ioredis:
specifier: ^6.0.0
version: 6.0.0(supports-color@7.2.0)
jsonrepair:
specifier: ^3.15.0
version: 3.15.0
ollama-ai-provider-v2:
specifier: ^4.0.1
version: 4.0.1(ai@7.0.66(zod@4.4.3))(zod@4.4.3)
@@ -750,6 +762,9 @@ importers:
sharp:
specifier: ^0.35.3
version: 0.35.3(@types/node@26.2.0)
tokenx:
specifier: ^2.1.0
version: 2.1.0
ts-pattern:
specifier: ^5.9.0
version: 5.9.0
@@ -3879,6 +3894,20 @@ packages:
'@selderee/plugin-htmlparser2@0.11.0':
resolution: {integrity: sha512-P33hHGdldxGabLFjPPpaTxVolMrzrcegejx+0GxjrIb9Zv48D8yAIA/QTDR2dFl7Uz7urX8aX6+5bCZslr+gWQ==}
'@shadcn/helpers@0.2.0':
resolution: {integrity: sha512-wpcZNuRgdW16jLwjvh4mbREKpVFrGY+nBM3Okgic8b04sijN5CHW1Nl/AEMajsP3INaCTNnqMCouOalZ7OHvEQ==}
peerDependencies:
'@tanstack/ai': '>=0.40.0 <0.41.0'
'@tanstack/ai-client': '>=0.20.0 <0.21.0'
ai: '>=7.0.0 <8'
peerDependenciesMeta:
'@tanstack/ai':
optional: true
'@tanstack/ai-client':
optional: true
ai:
optional: true
'@shadcn/react@0.3.0':
resolution: {integrity: sha512-iKN0NuYe850VDHlxEfvppFrpa7CMV3zArTHusXlaSmeFeQhohGbIqclv6WwPTs/44I8EkXQpcuRt6sXEVKkWqQ==}
peerDependencies:
@@ -8218,6 +8247,10 @@ packages:
resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}
engines: {node: '>=0.6'}
tokenx@2.1.0:
resolution: {integrity: sha512-iHhqfDuFFbMWHGfjEnVALgatV10KqcO5W5Fl99fYJmFjhE57JXPdnFrDlp6BTFIMmbbazsCg/lZYpJ2mPsPeQQ==}
hasBin: true
tree-kill@1.2.2:
resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==}
hasBin: true
@@ -11252,6 +11285,10 @@ snapshots:
domhandler: 5.0.3
selderee: 0.11.0
'@shadcn/helpers@0.2.0(ai@7.0.66(zod@4.4.3))':
optionalDependencies:
ai: 7.0.66(zod@4.4.3)
'@shadcn/react@0.3.0(@types/react@19.2.18)(react@19.2.8)':
optionalDependencies:
'@types/react': 19.2.18
@@ -15632,6 +15669,8 @@ snapshots:
toidentifier@1.0.1: {}
tokenx@2.1.0: {}
tree-kill@1.2.2: {}
trim-lines@3.0.1: {}