runtime-event-normalizer.test.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  1. import { describe, expect, it } from "vitest";
  2. import { normalizeTuiRuntimeEvent } from "../../src/runtime/event-normalizer.js";
  3. describe("normalizeTuiRuntimeEvent", () => {
  4. it("normalizes actionable LLM retry metadata without exposing provider messages", () => {
  5. expect(
  6. normalizeTuiRuntimeEvent({
  7. type: "session.llm_retry",
  8. timestamp: 90,
  9. source: "runtime",
  10. payload: {
  11. schemaVersion: 1,
  12. sessionId: "session-1",
  13. turnId: "turn-1",
  14. callId: "call-1",
  15. scope: "agent",
  16. status: "waiting",
  17. retryAttempt: 2,
  18. maxRetries: 5,
  19. requestAttempt: 3,
  20. delayMs: 2_500,
  21. nextRetryAtMs: 3_000,
  22. error: {
  23. reason: "rate_limited",
  24. code: 50_111,
  25. message: "secret provider detail",
  26. },
  27. },
  28. }),
  29. ).toEqual({
  30. type: "session.llm_retry",
  31. timestampMs: 90,
  32. source: "runtime",
  33. sessionId: "session-1",
  34. turnId: "turn-1",
  35. callId: "call-1",
  36. scope: "agent",
  37. status: "waiting",
  38. retryAttempt: 2,
  39. maxRetries: 5,
  40. requestAttempt: 3,
  41. delayMs: 2_500,
  42. nextRetryAtMs: 3_000,
  43. error: { reason: "rate_limited", code: 50_111 },
  44. });
  45. });
  46. it("rejects a non-object product event payload at the TUI boundary", () => {
  47. expect(
  48. normalizeTuiRuntimeEvent({
  49. type: "session.llm_retry",
  50. timestamp: 91,
  51. source: "runtime",
  52. payload: "invalid",
  53. }),
  54. ).toEqual({
  55. type: "unknown",
  56. originalType: "session.llm_retry",
  57. timestampMs: 91,
  58. source: "runtime",
  59. });
  60. });
  61. it("normalizes queue fields before they reach a product surface", () => {
  62. expect(
  63. normalizeTuiRuntimeEvent({
  64. type: "session.queue.updated",
  65. timestamp: 100,
  66. source: "runtime",
  67. payload: {
  68. session_id: "session-1",
  69. item_id: "queue-1",
  70. status: "failed",
  71. queued_count: 0,
  72. failed_reason: "provider unavailable",
  73. },
  74. }),
  75. ).toEqual({
  76. type: "session.queue.updated",
  77. timestampMs: 100,
  78. source: "runtime",
  79. sessionId: "session-1",
  80. itemId: "queue-1",
  81. status: "failed",
  82. queuedCount: 0,
  83. failedReason: "provider unavailable",
  84. });
  85. });
  86. it("normalizes Runtime-owned Goal updates and clears", () => {
  87. expect(
  88. normalizeTuiRuntimeEvent({
  89. type: "thread_goal.updated",
  90. timestamp: 110,
  91. source: "local-runtime",
  92. payload: {
  93. goal: {
  94. goalId: "goal-1",
  95. sessionId: "session-1",
  96. objective: "Ship TUI Goal support",
  97. status: "active",
  98. createdAt: 100,
  99. updatedAt: 105,
  100. tokensUsed: 1200,
  101. turnsUsed: 3,
  102. timeUsedSeconds: 42,
  103. tokenBudget: null,
  104. statusReason: "paused(verifier_unavailable)",
  105. lastVerification: {
  106. backend: "evaluator",
  107. verdict: "not_met",
  108. reason: "Focused evidence is missing.",
  109. missing: ["focused tests"],
  110. notMetStreak: 2,
  111. at: 104,
  112. },
  113. hasKickoffAttachments: true,
  114. },
  115. },
  116. }),
  117. ).toEqual({
  118. type: "thread_goal.updated",
  119. timestampMs: 110,
  120. source: "local-runtime",
  121. sessionId: "session-1",
  122. goal: {
  123. goalId: "goal-1",
  124. sessionId: "session-1",
  125. objective: "Ship TUI Goal support",
  126. status: "active",
  127. createdAt: 100,
  128. updatedAt: 105,
  129. tokensUsed: 1200,
  130. turnsUsed: 3,
  131. timeUsedSeconds: 42,
  132. tokenBudget: null,
  133. statusReason: "paused(verifier_unavailable)",
  134. lastVerification: {
  135. backend: "evaluator",
  136. verdict: "not_met",
  137. reason: "Focused evidence is missing.",
  138. missing: ["focused tests"],
  139. notMetStreak: 2,
  140. at: 104,
  141. },
  142. hasKickoffAttachments: true,
  143. },
  144. });
  145. expect(
  146. normalizeTuiRuntimeEvent({
  147. type: "thread_goal.cleared",
  148. timestamp: 111,
  149. source: "local-runtime",
  150. payload: { sessionId: "session-1", goalId: "goal-1" },
  151. }),
  152. ).toEqual({
  153. type: "thread_goal.cleared",
  154. timestampMs: 111,
  155. source: "local-runtime",
  156. sessionId: "session-1",
  157. goalId: "goal-1",
  158. });
  159. });
  160. it("fails closed for unknown Goal status and reason values", () => {
  161. const event = normalizeTuiRuntimeEvent({
  162. type: "thread_goal.updated",
  163. timestamp: 112,
  164. source: "local-runtime",
  165. payload: {
  166. goal: {
  167. goalId: "goal-1",
  168. sessionId: "session-1",
  169. objective: "Stay safe on future contract values",
  170. status: "future_status",
  171. createdAt: 100,
  172. updatedAt: 105,
  173. tokensUsed: 0,
  174. timeUsedSeconds: 0,
  175. tokenBudget: null,
  176. statusReason: "future(reason)",
  177. hasKickoffAttachments: false,
  178. },
  179. },
  180. });
  181. expect(event).toMatchObject({
  182. type: "thread_goal.updated",
  183. goal: {
  184. status: "paused",
  185. statusReason: null,
  186. },
  187. });
  188. });
  189. it("normalizes a typed Goal execution wait while older events remain compatible", () => {
  190. const event = normalizeTuiRuntimeEvent({
  191. type: "thread_goal.updated",
  192. timestamp: 113,
  193. source: "local-runtime",
  194. payload: {
  195. goal: {
  196. goalId: "goal-1",
  197. sessionId: "session-1",
  198. objective: "Wait for the required task",
  199. status: "active",
  200. createdAt: 100,
  201. updatedAt: 105,
  202. tokensUsed: 0,
  203. timeUsedSeconds: 4,
  204. tokenBudget: null,
  205. execution_wait: {
  206. wait_reason: "required_background",
  207. wait_since: 106,
  208. },
  209. hasKickoffAttachments: false,
  210. },
  211. },
  212. });
  213. expect(event).toMatchObject({
  214. type: "thread_goal.updated",
  215. goal: {
  216. executionWait: { reason: "required_background", sinceMs: 106 },
  217. },
  218. });
  219. });
  220. it("normalizes the verification wait a long verifier dispatch publishes", () => {
  221. const event = normalizeTuiRuntimeEvent({
  222. type: "thread_goal.updated",
  223. timestamp: 113,
  224. source: "local-runtime",
  225. payload: {
  226. goal: {
  227. goalId: "goal-1",
  228. sessionId: "session-1",
  229. objective: "Prove the release is ready",
  230. status: "active",
  231. createdAt: 100,
  232. updatedAt: 105,
  233. tokensUsed: 0,
  234. timeUsedSeconds: 4,
  235. tokenBudget: null,
  236. executionWait: { reason: "verification", sinceMs: 106 },
  237. hasKickoffAttachments: false,
  238. },
  239. },
  240. });
  241. expect(event).toMatchObject({
  242. type: "thread_goal.updated",
  243. goal: { executionWait: { reason: "verification", sinceMs: 106 } },
  244. });
  245. });
  246. it("preserves the Runtime V2 admission rejection reason for queue recovery UI", () => {
  247. expect(
  248. normalizeTuiRuntimeEvent({
  249. type: "session.queue.updated",
  250. timestamp: 100,
  251. source: "runtime-v2",
  252. payload: {
  253. sessionId: "session-1",
  254. itemId: "queue-rejected",
  255. status: "admission-rejected",
  256. reason: "admission-rejected",
  257. admissionReason: "ingress-conflict",
  258. },
  259. }),
  260. ).toEqual({
  261. type: "session.queue.updated",
  262. timestampMs: 100,
  263. source: "runtime-v2",
  264. sessionId: "session-1",
  265. itemId: "queue-rejected",
  266. status: "admission-rejected",
  267. reason: "admission-rejected",
  268. admissionReason: "ingress-conflict",
  269. });
  270. });
  271. it("preserves a Runtime Turn failure reason for product presentation", () => {
  272. expect(
  273. normalizeTuiRuntimeEvent({
  274. type: "session.error",
  275. timestamp: 101,
  276. source: "runtime",
  277. payload: {
  278. sessionId: "session-1",
  279. turnId: "turn-1",
  280. error: "provider unavailable",
  281. errorCode: 429,
  282. errorSource: "byok_upstream",
  283. errorDetail: "upstream socket closed",
  284. errorProviderId: "custom-provider",
  285. },
  286. }),
  287. ).toMatchObject({
  288. type: "session.error",
  289. sessionId: "session-1",
  290. turnId: "turn-1",
  291. error: "provider unavailable",
  292. errorCode: 429,
  293. errorSource: "byok_upstream",
  294. errorDetail: "upstream socket closed",
  295. errorProviderId: "custom-provider",
  296. });
  297. });
  298. it("preserves task child identity and delegated lifecycle correlation", () => {
  299. expect(
  300. normalizeTuiRuntimeEvent({
  301. type: "session.created",
  302. timestamp: 102,
  303. source: "runtime",
  304. payload: {
  305. sessionId: "session-child",
  306. agentName: "verifier",
  307. sessionType: "branch",
  308. sessionKind: "task",
  309. visibility: "hidden",
  310. parentSessionId: "session-root",
  311. title: "Review recent changes",
  312. },
  313. }),
  314. ).toMatchObject({
  315. type: "session.created",
  316. sessionId: "session-child",
  317. agentName: "verifier",
  318. sessionType: "branch",
  319. sessionKind: "task",
  320. visibility: "hidden",
  321. parentSessionId: "session-root",
  322. });
  323. expect(
  324. normalizeTuiRuntimeEvent({
  325. type: "session.start",
  326. timestamp: 103,
  327. source: "runtime",
  328. payload: {
  329. sessionId: "session-child",
  330. turnId: "turn-child",
  331. taskId: "task-1",
  332. source: "subagent-headless-turn",
  333. },
  334. }),
  335. ).toMatchObject({
  336. type: "session.start",
  337. sessionId: "session-child",
  338. taskId: "task-1",
  339. runSource: "subagent-headless-turn",
  340. });
  341. });
  342. it("validates questionnaire payloads at the Runtime boundary", () => {
  343. expect(
  344. normalizeTuiRuntimeEvent({
  345. type: "questionnaire.ask",
  346. timestamp: 101,
  347. source: "runtime",
  348. payload: {
  349. sessionId: "session-1",
  350. request: {
  351. schemaVersion: 2,
  352. id: "question-1",
  353. mode: "plan",
  354. modePayload: {
  355. planReview: {
  356. markdown: "# Frozen plan",
  357. path: "/history/session-1/artifacts/plan.md",
  358. },
  359. },
  360. tool: { messageId: "message-1", callId: "call-1" },
  361. presentation: {
  362. replaceComposer: true,
  363. showProgress: true,
  364. allowBackNavigation: true,
  365. },
  366. steps: [
  367. {
  368. id: "step-1",
  369. question: "Proceed?",
  370. selectionMode: "single",
  371. allowOther: true,
  372. otherPlaceholder: "Others...",
  373. required: true,
  374. image: { src: "data:image/png;base64,step", alt: "Step image" },
  375. options: [
  376. {
  377. id: "yes",
  378. label: "Yes",
  379. image: {
  380. src: "data:image/png;base64,option",
  381. caption: "Option image",
  382. },
  383. },
  384. ],
  385. },
  386. ],
  387. },
  388. },
  389. }),
  390. ).toMatchObject({
  391. type: "questionnaire.ask",
  392. sessionId: "session-1",
  393. request: {
  394. id: "question-1",
  395. mode: "plan",
  396. modePayload: {
  397. planReview: {
  398. markdown: "# Frozen plan",
  399. path: "/history/session-1/artifacts/plan.md",
  400. },
  401. },
  402. tool: { messageId: "message-1", callId: "call-1" },
  403. steps: [
  404. expect.objectContaining({
  405. id: "step-1",
  406. question: "Proceed?",
  407. selectionMode: "single",
  408. image: { src: "data:image/png;base64,step", alt: "Step image" },
  409. options: [
  410. expect.objectContaining({
  411. id: "yes",
  412. label: "Yes",
  413. image: {
  414. src: "data:image/png;base64,option",
  415. caption: "Option image",
  416. },
  417. }),
  418. ],
  419. }),
  420. ],
  421. },
  422. });
  423. });
  424. it("preserves Goal purpose and defaults a missing mode to questionnaire", () => {
  425. expect(
  426. normalizeTuiRuntimeEvent({
  427. type: "questionnaire.ask",
  428. timestamp: 102,
  429. source: "runtime",
  430. payload: {
  431. sessionId: "session-goal",
  432. request: {
  433. schemaVersion: 2,
  434. id: "question-goal",
  435. purpose: 1,
  436. expiresAt: 1_700_000_300_000,
  437. presentation: {
  438. replaceComposer: true,
  439. showProgress: true,
  440. allowBackNavigation: true,
  441. },
  442. steps: [
  443. {
  444. id: "direction",
  445. question: "Which direction?",
  446. selectionMode: "single",
  447. options: [
  448. { id: "safe", label: "Safe" },
  449. { id: "fast", label: "Fast", recommended: true },
  450. ],
  451. },
  452. ],
  453. },
  454. },
  455. }),
  456. ).toMatchObject({
  457. type: "questionnaire.ask",
  458. request: {
  459. id: "question-goal",
  460. purpose: "goal",
  461. mode: "questionnaire",
  462. expiresAt: 1_700_000_300_000,
  463. steps: [
  464. {
  465. options: [
  466. { id: "safe", label: "Safe" },
  467. { id: "fast", label: "Fast", recommended: true },
  468. ],
  469. },
  470. ],
  471. },
  472. });
  473. });
  474. it("fails closed for an unknown Questionnaire purpose", () => {
  475. expect(
  476. normalizeTuiRuntimeEvent({
  477. type: "questionnaire.ask",
  478. timestamp: 103,
  479. source: "runtime",
  480. payload: {
  481. sessionId: "session-1",
  482. request: {
  483. schemaVersion: 2,
  484. id: "question-unknown-purpose",
  485. purpose: 99,
  486. presentation: {
  487. replaceComposer: true,
  488. showProgress: true,
  489. allowBackNavigation: true,
  490. },
  491. steps: [],
  492. },
  493. },
  494. }),
  495. ).toMatchObject({ type: "unknown", originalType: "questionnaire.ask" });
  496. });
  497. it.each([
  498. { label: "legacy schema", patch: { schemaVersion: 1 } },
  499. { label: "missing presentation", patch: { presentation: undefined } },
  500. {
  501. label: "partial presentation",
  502. patch: {
  503. presentation: {
  504. replaceComposer: true,
  505. showProgress: false,
  506. allowBackNavigation: true,
  507. },
  508. },
  509. },
  510. ])("rejects a Plan request with $label", ({ patch }) => {
  511. expect(
  512. normalizeTuiRuntimeEvent({
  513. type: "questionnaire.ask",
  514. timestamp: 101,
  515. source: "runtime",
  516. payload: {
  517. sessionId: "session-1",
  518. request: {
  519. schemaVersion: 2,
  520. id: "plan-strict-envelope",
  521. mode: "plan",
  522. presentation: {
  523. replaceComposer: true,
  524. showProgress: true,
  525. allowBackNavigation: true,
  526. },
  527. steps: [
  528. {
  529. id: "plan-enter",
  530. question: "Enter Plan Mode?",
  531. selectionMode: "single",
  532. options: [
  533. { id: "confirm", label: "Confirm" },
  534. { id: "decline", label: "Decline" },
  535. ],
  536. allowOther: true,
  537. otherPlaceholder: "Others...",
  538. required: true,
  539. },
  540. ],
  541. ...patch,
  542. },
  543. },
  544. }),
  545. ).toMatchObject({ type: "unknown", originalType: "questionnaire.ask" });
  546. });
  547. it.each([
  548. {
  549. label: "legacy top-level Plan review",
  550. request: {
  551. id: "legacy-plan",
  552. mode: "plan",
  553. planReview: { markdown: "# Plan", path: "/plan.md" },
  554. steps: [],
  555. },
  556. },
  557. {
  558. label: "Plan payload on a generic questionnaire",
  559. request: {
  560. id: "wrong-mode",
  561. mode: "questionnaire",
  562. modePayload: { planReview: { markdown: "# Plan", path: "/plan.md" } },
  563. steps: [],
  564. },
  565. },
  566. {
  567. label: "empty frozen Markdown",
  568. request: {
  569. id: "empty-markdown",
  570. mode: "plan",
  571. modePayload: { planReview: { markdown: " ", path: "/plan.md" } },
  572. steps: [],
  573. },
  574. },
  575. {
  576. label: "empty canonical path",
  577. request: {
  578. id: "empty-path",
  579. mode: "plan",
  580. modePayload: { planReview: { markdown: "# Plan", path: " " } },
  581. steps: [],
  582. },
  583. },
  584. ])("fails closed for $label", ({ request }) => {
  585. expect(
  586. normalizeTuiRuntimeEvent({
  587. type: "questionnaire.ask",
  588. timestamp: 101,
  589. source: "runtime",
  590. payload: { sessionId: "session-1", request },
  591. }),
  592. ).toMatchObject({ type: "unknown", originalType: "questionnaire.ask" });
  593. });
  594. it("fails closed to an unknown product event for malformed interactions", () => {
  595. expect(
  596. normalizeTuiRuntimeEvent({
  597. type: "permission.ask",
  598. timestamp: 102,
  599. source: "runtime",
  600. payload: { sessionId: "session-1" },
  601. }),
  602. ).toEqual({
  603. type: "unknown",
  604. originalType: "permission.ask",
  605. timestampMs: 102,
  606. source: "runtime",
  607. sessionId: "session-1",
  608. });
  609. });
  610. it("preserves the authoritative permission decision for product presentation", () => {
  611. expect(
  612. normalizeTuiRuntimeEvent({
  613. type: "permission.resolved",
  614. timestamp: 103,
  615. source: "runtime",
  616. payload: {
  617. session_id: "session-1",
  618. request_id: "permission-1",
  619. decision: "allowAlways",
  620. },
  621. }),
  622. ).toEqual({
  623. type: "permission.resolved",
  624. timestampMs: 103,
  625. source: "runtime",
  626. sessionId: "session-1",
  627. requestId: "permission-1",
  628. decision: "allowAlways",
  629. });
  630. });
  631. it("preserves the Runtime permission timestamp used for transcript ordering", () => {
  632. expect(
  633. normalizeTuiRuntimeEvent({
  634. type: "permission.ask",
  635. timestamp: 500,
  636. source: "runtime",
  637. payload: {
  638. sessionId: "session-1",
  639. requestId: "permission-ordered",
  640. toolName: "edit",
  641. toolInput: JSON.stringify({
  642. path: "src/greeting.ts",
  643. edits: [{ oldText: "old", newText: "new" }],
  644. }),
  645. createdAt: 123,
  646. },
  647. }),
  648. ).toMatchObject({
  649. type: "permission.ask",
  650. request: {
  651. requestId: "permission-ordered",
  652. createdAt: 123,
  653. structuredPreview: {
  654. schemaVersion: 1,
  655. state: "proposed",
  656. blocks: [
  657. expect.objectContaining({ kind: "diff", path: "src/greeting.ts" }),
  658. ],
  659. },
  660. },
  661. });
  662. });
  663. it.each([
  664. [
  665. "content.retry.exceeded",
  666. {
  667. sessionId: "session-1",
  668. variant: "content",
  669. lastUserMsgId: "message-user",
  670. },
  671. { variant: "content", lastUserMsgId: "message-user" },
  672. ],
  673. [
  674. "message.rewind",
  675. { sessionId: "session-1", contextReset: true },
  676. { contextReset: true },
  677. ],
  678. [
  679. "session.compaction.completed",
  680. {
  681. sessionId: "session-1",
  682. compactionId: "compact-1",
  683. messagesBefore: 10,
  684. messagesAfter: 3,
  685. tokensBefore: 1_000,
  686. tokensAfter: 300,
  687. tokenUsage: {
  688. inputTokens: 1_000,
  689. outputTokens: 300,
  690. cacheReadTokens: 20,
  691. cacheWriteTokens: 5,
  692. totalTokens: 1_325,
  693. incomplete: true,
  694. },
  695. },
  696. {
  697. compactionId: "compact-1",
  698. messagesBefore: 10,
  699. messagesAfter: 3,
  700. tokensBefore: 1_000,
  701. tokensAfter: 300,
  702. tokenUsage: {
  703. inputTokens: 1_000,
  704. outputTokens: 300,
  705. cacheReadTokens: 20,
  706. cacheWriteTokens: 5,
  707. totalTokens: 1_325,
  708. incomplete: true,
  709. },
  710. },
  711. ],
  712. [
  713. "session.title_updated",
  714. { sessionId: "session-1", title: "Renamed elsewhere" },
  715. { title: "Renamed elsewhere" },
  716. ],
  717. ] as const)("normalizes the %s owner event", (type, payload, expected) => {
  718. expect(
  719. normalizeTuiRuntimeEvent({
  720. type,
  721. timestamp: 600,
  722. source: "runtime",
  723. payload,
  724. }),
  725. ).toMatchObject({ type, sessionId: "session-1", ...expected });
  726. });
  727. it("preserves content-review authentication failures for an actionable warning", () => {
  728. expect(
  729. normalizeTuiRuntimeEvent({
  730. type: "content.retry.exceeded",
  731. timestamp: 650,
  732. source: "runtime",
  733. payload: { sessionId: "session-1", variant: "auth" },
  734. }),
  735. ).toMatchObject({
  736. type: "content.retry.exceeded",
  737. sessionId: "session-1",
  738. variant: "auth",
  739. });
  740. });
  741. it("normalizes Session rotation without inventing an active Session id", () => {
  742. expect(
  743. normalizeTuiRuntimeEvent({
  744. type: "rotation.completed",
  745. timestamp: 700,
  746. source: "runtime",
  747. payload: {
  748. agentName: "mavis",
  749. oldSessionId: "session-old",
  750. newSessionId: "session-new",
  751. reason: "context-limit",
  752. },
  753. }),
  754. ).toEqual({
  755. type: "rotation.completed",
  756. timestampMs: 700,
  757. source: "runtime",
  758. agentName: "mavis",
  759. oldSessionId: "session-old",
  760. newSessionId: "session-new",
  761. reason: "context-limit",
  762. });
  763. });
  764. });