@voicethere/agent 0.22.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +2 -0
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/llm/agent/config.d.ts +5 -0
  6. package/dist/llm/agent/config.d.ts.map +1 -1
  7. package/dist/llm/agent/config.js +1 -0
  8. package/dist/llm/agent/config.js.map +1 -1
  9. package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
  10. package/dist/llm/agent/create-llm-agent.js +37 -0
  11. package/dist/llm/agent/create-llm-agent.js.map +1 -1
  12. package/dist/llm/agent/hooks.d.ts +5 -1
  13. package/dist/llm/agent/hooks.d.ts.map +1 -1
  14. package/dist/llm/anthropic-provider.d.ts.map +1 -1
  15. package/dist/llm/anthropic-provider.js +9 -4
  16. package/dist/llm/anthropic-provider.js.map +1 -1
  17. package/dist/llm/gemini-provider.d.ts.map +1 -1
  18. package/dist/llm/gemini-provider.js +4 -0
  19. package/dist/llm/gemini-provider.js.map +1 -1
  20. package/dist/llm/index.d.ts +1 -1
  21. package/dist/llm/index.d.ts.map +1 -1
  22. package/dist/llm/index.js.map +1 -1
  23. package/dist/llm/openai-provider.d.ts.map +1 -1
  24. package/dist/llm/openai-provider.js +4 -0
  25. package/dist/llm/openai-provider.js.map +1 -1
  26. package/dist/llm/types.d.ts +14 -4
  27. package/dist/llm/types.d.ts.map +1 -1
  28. package/dist/llm/types.js.map +1 -1
  29. package/dist/protocol.d.ts +22 -1
  30. package/dist/protocol.d.ts.map +1 -1
  31. package/dist/protocol.js.map +1 -1
  32. package/dist/sandbox/sandbox.d.ts +3 -0
  33. package/dist/sandbox/sandbox.d.ts.map +1 -1
  34. package/dist/sandbox/sandbox.js +15 -0
  35. package/dist/sandbox/sandbox.js.map +1 -1
  36. package/dist/sandbox/start-child.d.ts.map +1 -1
  37. package/dist/sandbox/start-child.js +11 -0
  38. package/dist/sandbox/start-child.js.map +1 -1
  39. package/dist/sandbox/warning-forwarder.cjs +35 -0
  40. package/dist/templates/llm-agent/agent.js +31 -3
  41. package/dist/templates/llm-docs-rag/agent.js +31 -3
  42. package/dist/templates/llm-mcp-service/agent.js +31 -3
  43. package/eject/llm/loop.ts +48 -1
  44. package/package.json +2 -2
  45. package/schema/voicethere.llm.schema.json +2 -1
  46. package/templates/llm-agent/README.md +4 -0
  47. package/templates/llm-agent/voicethere.llm.json +1 -1
  48. package/templates/llm-docs-rag/README.md +4 -0
  49. package/templates/llm-docs-rag/voicethere.llm.json +1 -1
  50. package/templates/llm-mcp-service/README.md +4 -0
  51. package/templates/llm-mcp-service/voicethere.llm.json +1 -1
@@ -34568,7 +34568,8 @@ var LLM_AGENT_CONFIG_JSON_SCHEMA = {
34568
34568
  type: "integer",
34569
34569
  minimum: 1,
34570
34570
  maximum: 8192,
34571
- default: 512
34571
+ default: 512,
34572
+ description: "Output token cap per LLM call. Thinking models count hidden reasoning against maxOutputTokens; keep spoken replies short in the prompt, not with a small cap. A reply cut off before anything was spoken fails the turn with LLM_OUTPUT_TRUNCATED."
34572
34573
  },
34573
34574
  toolChoice: {
34574
34575
  enum: ["auto", "required-first-round"],
@@ -35935,7 +35936,11 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
35935
35936
  if (done.usage.outputTokens !== void 0) {
35936
35937
  t.outputTokens = (t.outputTokens ?? 0) + done.usage.outputTokens;
35937
35938
  }
35939
+ if (done.usage.reasoningTokens !== void 0) {
35940
+ t.reasoningTokens = (t.reasoningTokens ?? 0) + done.usage.reasoningTokens;
35941
+ }
35938
35942
  }
35943
+ t.stopReason = done.stopReason;
35939
35944
  t.roundOpen = false;
35940
35945
  return done;
35941
35946
  }
@@ -35949,6 +35954,8 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
35949
35954
  ...t.firstTokenMs !== void 0 ? { firstTokenMs: t.firstTokenMs } : {},
35950
35955
  ...t.inputTokens !== void 0 ? { inputTokens: t.inputTokens } : {},
35951
35956
  ...t.outputTokens !== void 0 ? { outputTokens: t.outputTokens } : {},
35957
+ ...t.reasoningTokens !== void 0 ? { reasoningTokens: t.reasoningTokens } : {},
35958
+ ...t.stopReason !== void 0 ? { stopReason: t.stopReason } : {},
35952
35959
  ...t.errorCode ? { errorCode: t.errorCode } : {},
35953
35960
  ...t.linkUrls.size > 0 ? { linksSent: t.linkUrls.size } : {},
35954
35961
  ...t.linksDropped > 0 ? { linksDropped: t.linksDropped } : {}
@@ -35988,6 +35995,23 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
35988
35995
  for (let round = 0; round < maxRounds; round += 1) {
35989
35996
  const done = await runRound(s, t, ctx);
35990
35997
  const calls = done.toolCalls;
35998
+ if (calls.length === 0 && done.stopReason === "max_tokens") {
35999
+ const partial2 = t.roundText.trim().length > 0;
36000
+ agentLog("warn", "llm turn truncated: LLM_OUTPUT_TRUNCATED", {
36001
+ code: "LLM_OUTPUT_TRUNCATED",
36002
+ round: round + 1,
36003
+ outputTokens: done.usage?.outputTokens,
36004
+ ...done.usage?.reasoningTokens !== void 0 ? { reasoningTokens: done.usage.reasoningTokens } : {},
36005
+ maxOutputTokens: config2.maxOutputTokens ?? D.maxOutputTokens,
36006
+ partial: partial2
36007
+ }, s.sessionId);
36008
+ if (!partial2) {
36009
+ t.errorCode = "LLM_OUTPUT_TRUNCATED";
36010
+ speakFallback(s, t);
36011
+ t.status = "failed";
36012
+ return summarize(t);
36013
+ }
36014
+ }
35991
36015
  if (calls.length === 0) {
35992
36016
  s.history.addAssistant({
35993
36017
  role: "assistant",
@@ -36128,6 +36152,8 @@ ${t.inputText}` : t.inputText, {
36128
36152
  firstTokenMs: summary.firstTokenMs,
36129
36153
  inputTokens: summary.inputTokens,
36130
36154
  outputTokens: summary.outputTokens,
36155
+ reasoningTokens: summary.reasoningTokens,
36156
+ stopReason: summary.stopReason,
36131
36157
  thinkingCharsStripped: t.thinkingCharsStripped,
36132
36158
  linksSent: t.linkUrls.size,
36133
36159
  linksDropped: t.linksDropped
@@ -59760,9 +59786,11 @@ function createOpenAiCompatibleProvider(config2) {
59760
59786
  const acc = /* @__PURE__ */ new Map();
59761
59787
  for await (const chunk of stream) {
59762
59788
  if (chunk.usage) {
59789
+ const reasoning = chunk.usage.completion_tokens_details?.reasoning_tokens;
59763
59790
  usage = {
59764
59791
  inputTokens: chunk.usage.prompt_tokens,
59765
- outputTokens: chunk.usage.completion_tokens
59792
+ outputTokens: chunk.usage.completion_tokens,
59793
+ ...typeof reasoning === "number" ? { reasoningTokens: reasoning } : {}
59766
59794
  };
59767
59795
  }
59768
59796
  const choice = chunk.choices?.[0];
@@ -59846,7 +59874,7 @@ var voicethere_llm_default = {
59846
59874
  provider: "openrouter",
59847
59875
  model: "anthropic/claude-haiku-5.5",
59848
59876
  apiKeySecret: "AGENT_OPENROUTER_API_KEY",
59849
- maxOutputTokens: 300,
59877
+ maxOutputTokens: 1024,
59850
59878
  greeting: {
59851
59879
  text: "Hi! How can I help you today?",
59852
59880
  interruptible: true
@@ -34568,7 +34568,8 @@ var LLM_AGENT_CONFIG_JSON_SCHEMA = {
34568
34568
  type: "integer",
34569
34569
  minimum: 1,
34570
34570
  maximum: 8192,
34571
- default: 512
34571
+ default: 512,
34572
+ description: "Output token cap per LLM call. Thinking models count hidden reasoning against maxOutputTokens; keep spoken replies short in the prompt, not with a small cap. A reply cut off before anything was spoken fails the turn with LLM_OUTPUT_TRUNCATED."
34572
34573
  },
34573
34574
  toolChoice: {
34574
34575
  enum: ["auto", "required-first-round"],
@@ -35935,7 +35936,11 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
35935
35936
  if (done.usage.outputTokens !== void 0) {
35936
35937
  t.outputTokens = (t.outputTokens ?? 0) + done.usage.outputTokens;
35937
35938
  }
35939
+ if (done.usage.reasoningTokens !== void 0) {
35940
+ t.reasoningTokens = (t.reasoningTokens ?? 0) + done.usage.reasoningTokens;
35941
+ }
35938
35942
  }
35943
+ t.stopReason = done.stopReason;
35939
35944
  t.roundOpen = false;
35940
35945
  return done;
35941
35946
  }
@@ -35949,6 +35954,8 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
35949
35954
  ...t.firstTokenMs !== void 0 ? { firstTokenMs: t.firstTokenMs } : {},
35950
35955
  ...t.inputTokens !== void 0 ? { inputTokens: t.inputTokens } : {},
35951
35956
  ...t.outputTokens !== void 0 ? { outputTokens: t.outputTokens } : {},
35957
+ ...t.reasoningTokens !== void 0 ? { reasoningTokens: t.reasoningTokens } : {},
35958
+ ...t.stopReason !== void 0 ? { stopReason: t.stopReason } : {},
35952
35959
  ...t.errorCode ? { errorCode: t.errorCode } : {},
35953
35960
  ...t.linkUrls.size > 0 ? { linksSent: t.linkUrls.size } : {},
35954
35961
  ...t.linksDropped > 0 ? { linksDropped: t.linksDropped } : {}
@@ -35988,6 +35995,23 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
35988
35995
  for (let round = 0; round < maxRounds; round += 1) {
35989
35996
  const done = await runRound(s, t, ctx);
35990
35997
  const calls = done.toolCalls;
35998
+ if (calls.length === 0 && done.stopReason === "max_tokens") {
35999
+ const partial2 = t.roundText.trim().length > 0;
36000
+ agentLog("warn", "llm turn truncated: LLM_OUTPUT_TRUNCATED", {
36001
+ code: "LLM_OUTPUT_TRUNCATED",
36002
+ round: round + 1,
36003
+ outputTokens: done.usage?.outputTokens,
36004
+ ...done.usage?.reasoningTokens !== void 0 ? { reasoningTokens: done.usage.reasoningTokens } : {},
36005
+ maxOutputTokens: config2.maxOutputTokens ?? D.maxOutputTokens,
36006
+ partial: partial2
36007
+ }, s.sessionId);
36008
+ if (!partial2) {
36009
+ t.errorCode = "LLM_OUTPUT_TRUNCATED";
36010
+ speakFallback(s, t);
36011
+ t.status = "failed";
36012
+ return summarize(t);
36013
+ }
36014
+ }
35991
36015
  if (calls.length === 0) {
35992
36016
  s.history.addAssistant({
35993
36017
  role: "assistant",
@@ -36128,6 +36152,8 @@ ${t.inputText}` : t.inputText, {
36128
36152
  firstTokenMs: summary.firstTokenMs,
36129
36153
  inputTokens: summary.inputTokens,
36130
36154
  outputTokens: summary.outputTokens,
36155
+ reasoningTokens: summary.reasoningTokens,
36156
+ stopReason: summary.stopReason,
36131
36157
  thinkingCharsStripped: t.thinkingCharsStripped,
36132
36158
  linksSent: t.linkUrls.size,
36133
36159
  linksDropped: t.linksDropped
@@ -59760,9 +59786,11 @@ function createOpenAiCompatibleProvider(config2) {
59760
59786
  const acc = /* @__PURE__ */ new Map();
59761
59787
  for await (const chunk of stream) {
59762
59788
  if (chunk.usage) {
59789
+ const reasoning = chunk.usage.completion_tokens_details?.reasoning_tokens;
59763
59790
  usage = {
59764
59791
  inputTokens: chunk.usage.prompt_tokens,
59765
- outputTokens: chunk.usage.completion_tokens
59792
+ outputTokens: chunk.usage.completion_tokens,
59793
+ ...typeof reasoning === "number" ? { reasoningTokens: reasoning } : {}
59766
59794
  };
59767
59795
  }
59768
59796
  const choice = chunk.choices?.[0];
@@ -59846,7 +59874,7 @@ var voicethere_llm_default = {
59846
59874
  provider: "openrouter",
59847
59875
  model: "anthropic/claude-haiku-5.5",
59848
59876
  apiKeySecret: "AGENT_OPENROUTER_API_KEY",
59849
- maxOutputTokens: 300,
59877
+ maxOutputTokens: 1024,
59850
59878
  greeting: {
59851
59879
  text: "Hi! Ask me anything about our documentation.",
59852
59880
  interruptible: true
@@ -34568,7 +34568,8 @@ var LLM_AGENT_CONFIG_JSON_SCHEMA = {
34568
34568
  type: "integer",
34569
34569
  minimum: 1,
34570
34570
  maximum: 8192,
34571
- default: 512
34571
+ default: 512,
34572
+ description: "Output token cap per LLM call. Thinking models count hidden reasoning against maxOutputTokens; keep spoken replies short in the prompt, not with a small cap. A reply cut off before anything was spoken fails the turn with LLM_OUTPUT_TRUNCATED."
34572
34573
  },
34573
34574
  toolChoice: {
34574
34575
  enum: ["auto", "required-first-round"],
@@ -35935,7 +35936,11 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
35935
35936
  if (done.usage.outputTokens !== void 0) {
35936
35937
  t.outputTokens = (t.outputTokens ?? 0) + done.usage.outputTokens;
35937
35938
  }
35939
+ if (done.usage.reasoningTokens !== void 0) {
35940
+ t.reasoningTokens = (t.reasoningTokens ?? 0) + done.usage.reasoningTokens;
35941
+ }
35938
35942
  }
35943
+ t.stopReason = done.stopReason;
35939
35944
  t.roundOpen = false;
35940
35945
  return done;
35941
35946
  }
@@ -35949,6 +35954,8 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
35949
35954
  ...t.firstTokenMs !== void 0 ? { firstTokenMs: t.firstTokenMs } : {},
35950
35955
  ...t.inputTokens !== void 0 ? { inputTokens: t.inputTokens } : {},
35951
35956
  ...t.outputTokens !== void 0 ? { outputTokens: t.outputTokens } : {},
35957
+ ...t.reasoningTokens !== void 0 ? { reasoningTokens: t.reasoningTokens } : {},
35958
+ ...t.stopReason !== void 0 ? { stopReason: t.stopReason } : {},
35952
35959
  ...t.errorCode ? { errorCode: t.errorCode } : {},
35953
35960
  ...t.linkUrls.size > 0 ? { linksSent: t.linkUrls.size } : {},
35954
35961
  ...t.linksDropped > 0 ? { linksDropped: t.linksDropped } : {}
@@ -35988,6 +35995,23 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
35988
35995
  for (let round = 0; round < maxRounds; round += 1) {
35989
35996
  const done = await runRound(s, t, ctx);
35990
35997
  const calls = done.toolCalls;
35998
+ if (calls.length === 0 && done.stopReason === "max_tokens") {
35999
+ const partial2 = t.roundText.trim().length > 0;
36000
+ agentLog("warn", "llm turn truncated: LLM_OUTPUT_TRUNCATED", {
36001
+ code: "LLM_OUTPUT_TRUNCATED",
36002
+ round: round + 1,
36003
+ outputTokens: done.usage?.outputTokens,
36004
+ ...done.usage?.reasoningTokens !== void 0 ? { reasoningTokens: done.usage.reasoningTokens } : {},
36005
+ maxOutputTokens: config2.maxOutputTokens ?? D.maxOutputTokens,
36006
+ partial: partial2
36007
+ }, s.sessionId);
36008
+ if (!partial2) {
36009
+ t.errorCode = "LLM_OUTPUT_TRUNCATED";
36010
+ speakFallback(s, t);
36011
+ t.status = "failed";
36012
+ return summarize(t);
36013
+ }
36014
+ }
35991
36015
  if (calls.length === 0) {
35992
36016
  s.history.addAssistant({
35993
36017
  role: "assistant",
@@ -36128,6 +36152,8 @@ ${t.inputText}` : t.inputText, {
36128
36152
  firstTokenMs: summary.firstTokenMs,
36129
36153
  inputTokens: summary.inputTokens,
36130
36154
  outputTokens: summary.outputTokens,
36155
+ reasoningTokens: summary.reasoningTokens,
36156
+ stopReason: summary.stopReason,
36131
36157
  thinkingCharsStripped: t.thinkingCharsStripped,
36132
36158
  linksSent: t.linkUrls.size,
36133
36159
  linksDropped: t.linksDropped
@@ -59760,9 +59786,11 @@ function createOpenAiCompatibleProvider(config2) {
59760
59786
  const acc = /* @__PURE__ */ new Map();
59761
59787
  for await (const chunk of stream) {
59762
59788
  if (chunk.usage) {
59789
+ const reasoning = chunk.usage.completion_tokens_details?.reasoning_tokens;
59763
59790
  usage = {
59764
59791
  inputTokens: chunk.usage.prompt_tokens,
59765
- outputTokens: chunk.usage.completion_tokens
59792
+ outputTokens: chunk.usage.completion_tokens,
59793
+ ...typeof reasoning === "number" ? { reasoningTokens: reasoning } : {}
59766
59794
  };
59767
59795
  }
59768
59796
  const choice = chunk.choices?.[0];
@@ -59846,7 +59874,7 @@ var voicethere_llm_default = {
59846
59874
  provider: "openrouter",
59847
59875
  model: "anthropic/claude-haiku-5.5",
59848
59876
  apiKeySecret: "AGENT_OPENROUTER_API_KEY",
59849
- maxOutputTokens: 300,
59877
+ maxOutputTokens: 1024,
59850
59878
  greeting: {
59851
59879
  text: "Hi! How can I help you today?",
59852
59880
  interruptible: true
package/eject/llm/loop.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copied from @voicethere/agent 0.22.0. Package updates no longer change this file.
1
+ // Copied from @voicethere/agent 0.23.1. Package updates no longer change this file.
2
2
  import { randomUUID } from "node:crypto";
3
3
  import {
4
4
  type AgentHandlers,
@@ -39,6 +39,7 @@ import {
39
39
  type LlmProvider,
40
40
  LlmProviderError,
41
41
  type LlmProviderModule,
42
+ type LlmStopReason,
42
43
  type LlmStreamEvent,
43
44
  type LlmToolResult,
44
45
  McpToolSource,
@@ -110,6 +111,10 @@ interface TurnState {
110
111
  firstTokenMs?: number;
111
112
  inputTokens?: number;
112
113
  outputTokens?: number;
114
+ /** Hidden thinking share of `outputTokens`, when the provider reports it. */
115
+ reasoningTokens?: number;
116
+ /** Stop reason of the last LLM round of this turn. */
117
+ stopReason?: LlmStopReason;
113
118
  errorCode?: string;
114
119
  abortStatus?: "interrupted" | "cancelled";
115
120
  roundOpen: boolean;
@@ -1044,7 +1049,12 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
1044
1049
  if (done.usage.outputTokens !== undefined) {
1045
1050
  t.outputTokens = (t.outputTokens ?? 0) + done.usage.outputTokens;
1046
1051
  }
1052
+ if (done.usage.reasoningTokens !== undefined) {
1053
+ t.reasoningTokens =
1054
+ (t.reasoningTokens ?? 0) + done.usage.reasoningTokens;
1055
+ }
1047
1056
  }
1057
+ t.stopReason = done.stopReason;
1048
1058
  t.roundOpen = false;
1049
1059
  return done;
1050
1060
  }
@@ -1061,6 +1071,10 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
1061
1071
  ...(t.firstTokenMs !== undefined ? { firstTokenMs: t.firstTokenMs } : {}),
1062
1072
  ...(t.inputTokens !== undefined ? { inputTokens: t.inputTokens } : {}),
1063
1073
  ...(t.outputTokens !== undefined ? { outputTokens: t.outputTokens } : {}),
1074
+ ...(t.reasoningTokens !== undefined
1075
+ ? { reasoningTokens: t.reasoningTokens }
1076
+ : {}),
1077
+ ...(t.stopReason !== undefined ? { stopReason: t.stopReason } : {}),
1064
1078
  ...(t.errorCode ? { errorCode: t.errorCode } : {}),
1065
1079
  ...(t.linkUrls.size > 0 ? { linksSent: t.linkUrls.size } : {}),
1066
1080
  ...(t.linksDropped > 0 ? { linksDropped: t.linksDropped } : {}),
@@ -1102,6 +1116,37 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
1102
1116
  for (let round = 0; round < maxRounds; round += 1) {
1103
1117
  const done = await runRound(s, t, ctx);
1104
1118
  const calls = done.toolCalls;
1119
+ if (calls.length === 0 && done.stopReason === "max_tokens") {
1120
+ // The output cap cut the answer (thinking models spend hidden
1121
+ // reasoning tokens against it). Metadata only in the log.
1122
+ // Partial only when THIS answer round delivered text; a preamble
1123
+ // spoken before a tool call does not answer the caller.
1124
+ const partial = t.roundText.trim().length > 0;
1125
+ agentLog(
1126
+ "warn",
1127
+ "llm turn truncated: LLM_OUTPUT_TRUNCATED",
1128
+ {
1129
+ code: "LLM_OUTPUT_TRUNCATED",
1130
+ round: round + 1,
1131
+ outputTokens: done.usage?.outputTokens,
1132
+ ...(done.usage?.reasoningTokens !== undefined
1133
+ ? { reasoningTokens: done.usage.reasoningTokens }
1134
+ : {}),
1135
+ maxOutputTokens: config.maxOutputTokens ?? D.maxOutputTokens,
1136
+ partial,
1137
+ },
1138
+ s.sessionId,
1139
+ );
1140
+ if (!partial) {
1141
+ // Nothing reached the caller: same as any other failed turn.
1142
+ t.errorCode = "LLM_OUTPUT_TRUNCATED";
1143
+ speakFallback(s, t);
1144
+ t.status = "failed";
1145
+ return summarize(t);
1146
+ }
1147
+ // Text already reached the caller: keep it (never re-send) and
1148
+ // finish the turn as completed; the summary carries stopReason.
1149
+ }
1105
1150
  if (calls.length === 0) {
1106
1151
  s.history.addAssistant(
1107
1152
  {
@@ -1287,6 +1332,8 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
1287
1332
  firstTokenMs: summary.firstTokenMs,
1288
1333
  inputTokens: summary.inputTokens,
1289
1334
  outputTokens: summary.outputTokens,
1335
+ reasoningTokens: summary.reasoningTokens,
1336
+ stopReason: summary.stopReason,
1290
1337
  thinkingCharsStripped: t.thinkingCharsStripped,
1291
1338
  linksSent: t.linkUrls.size,
1292
1339
  linksDropped: t.linksDropped,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voicethere/agent",
3
- "version": "0.22.0",
3
+ "version": "0.23.1",
4
4
  "description": "VoiceThere customer agent SDK — IPC types and runtime helpers for sandboxed child bundles",
5
5
  "type": "module",
6
6
  "exports": {
@@ -92,7 +92,7 @@
92
92
  "LICENSE"
93
93
  ],
94
94
  "scripts": {
95
- "build:lib": "tsc -p tsconfig.json && mkdir -p dist/sandbox && cp src/sandbox/loader-entry.js dist/sandbox/",
95
+ "build:lib": "tsc -p tsconfig.json && mkdir -p dist/sandbox && cp src/sandbox/loader-entry.js src/sandbox/warning-forwarder.cjs dist/sandbox/",
96
96
  "build:schema": "node scripts/build-llm-schema.mjs",
97
97
  "build:eject": "node scripts/build-llm-eject.mjs",
98
98
  "build:templates": "node dist/templates/build-seed-bundles-cli.js",
@@ -40,7 +40,8 @@
40
40
  "type": "integer",
41
41
  "minimum": 1,
42
42
  "maximum": 8192,
43
- "default": 512
43
+ "default": 512,
44
+ "description": "Output token cap per LLM call. Thinking models count hidden reasoning against maxOutputTokens; keep spoken replies short in the prompt, not with a small cap. A reply cut off before anything was spoken fails the turn with LLM_OUTPUT_TRUNCATED."
44
45
  },
45
46
  "toolChoice": {
46
47
  "enum": ["auto", "required-first-round"],
@@ -85,6 +85,10 @@ createLlmAgent({
85
85
 
86
86
  It is never added automatically.
87
87
 
88
+ ## Output token cap
89
+
90
+ `maxOutputTokens` is 1024 in `voicethere.llm.json`. Thinking models count hidden reasoning against `maxOutputTokens`, so keep spoken replies short in the prompt, not with a small cap. A reply cut off by the cap before anything was spoken ends the turn with `LLM_OUTPUT_TRUNCATED` and the fallback text.
91
+
88
92
  ## Switch providers
89
93
 
90
94
  Change `provider`, `model` and `apiKeySecret` in `voicethere.llm.json`. To go back to OpenAI, use `provider: "openai"`, `model: "gpt-4o-mini"` and `AGENT_OPENAI_API_KEY`; no import changes. Other options are `anthropic` with `AGENT_ANTHROPIC_API_KEY` and `gemini` with `AGENT_GEMINI_API_KEY`. Create the matching project secret before you deploy.
@@ -4,7 +4,7 @@
4
4
  "provider": "openrouter",
5
5
  "model": "anthropic/claude-haiku-5.5",
6
6
  "apiKeySecret": "AGENT_OPENROUTER_API_KEY",
7
- "maxOutputTokens": 300,
7
+ "maxOutputTokens": 1024,
8
8
  "greeting": {
9
9
  "text": "Hi! How can I help you today?",
10
10
  "interruptible": true
@@ -38,6 +38,10 @@ Redeploy the project. The agent connects to `/mcp` on the service with the proje
38
38
  - `"toolChoice": "required-first-round"` makes every turn start with a docs search, so the answer comes from your docs and not from the model's memory. Remove it if the assistant should also handle small talk without searching.
39
39
  - Set the provider, model and API key as in the `llm-agent` template: the template starts on OpenRouter with `anthropic/claude-haiku-5.5`, key `AGENT_OPENROUTER_API_KEY` (a project secret).
40
40
 
41
+ ## Output token cap
42
+
43
+ `maxOutputTokens` is 1024 in `voicethere.llm.json`. Thinking models count hidden reasoning against `maxOutputTokens`, so keep spoken replies short in the prompt, not with a small cap. A reply cut off by the cap before anything was spoken ends the turn with `LLM_OUTPUT_TRUNCATED` and the fallback text.
44
+
41
45
  ## Files
42
46
 
43
47
  - `agent.ts` wires the pieces together. You rarely need to change it.
@@ -4,7 +4,7 @@
4
4
  "provider": "openrouter",
5
5
  "model": "anthropic/claude-haiku-5.5",
6
6
  "apiKeySecret": "AGENT_OPENROUTER_API_KEY",
7
- "maxOutputTokens": 300,
7
+ "maxOutputTokens": 1024,
8
8
  "greeting": {
9
9
  "text": "Hi! Ask me anything about our documentation.",
10
10
  "interruptible": true
@@ -109,6 +109,10 @@ createLlmAgent({
109
109
 
110
110
  It is never added automatically.
111
111
 
112
+ ## Output token cap
113
+
114
+ `maxOutputTokens` is 1024 in `voicethere.llm.json`. Thinking models count hidden reasoning against `maxOutputTokens`, so keep spoken replies short in the prompt, not with a small cap. A reply cut off by the cap before anything was spoken ends the turn with `LLM_OUTPUT_TRUNCATED` and the fallback text.
115
+
112
116
  ## Switch providers
113
117
 
114
118
  Change `provider`, `model` and `apiKeySecret` in `voicethere.llm.json`. To go back to OpenAI, use `provider: "openai"`, `model: "gpt-4o-mini"` and `AGENT_OPENAI_API_KEY`; no import changes. Other options are `anthropic` with `AGENT_ANTHROPIC_API_KEY` and `gemini` with `AGENT_GEMINI_API_KEY`. Create the matching project secret before you deploy.
@@ -4,7 +4,7 @@
4
4
  "provider": "openrouter",
5
5
  "model": "anthropic/claude-haiku-5.5",
6
6
  "apiKeySecret": "AGENT_OPENROUTER_API_KEY",
7
- "maxOutputTokens": 300,
7
+ "maxOutputTokens": 1024,
8
8
  "greeting": {
9
9
  "text": "Hi! How can I help you today?",
10
10
  "interruptible": true