@agi-cli/server 0.1.108 → 0.1.109

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agi-cli/server",
3
- "version": "0.1.108",
3
+ "version": "0.1.109",
4
4
  "description": "HTTP API server for AGI CLI",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -29,8 +29,8 @@
29
29
  "typecheck": "tsc --noEmit"
30
30
  },
31
31
  "dependencies": {
32
- "@agi-cli/sdk": "0.1.108",
33
- "@agi-cli/database": "0.1.108",
32
+ "@agi-cli/sdk": "0.1.109",
33
+ "@agi-cli/database": "0.1.109",
34
34
  "drizzle-orm": "^0.44.5",
35
35
  "hono": "^4.9.9",
36
36
  "zod": "^4.1.8"
@@ -120,6 +120,8 @@ export function registerSessionMessagesRoutes(app: Hono) {
120
120
  typeOf: typeof userContext,
121
121
  });
122
122
 
123
+ const reasoning = body?.reasoning === true;
124
+
123
125
  // Validate model capabilities if tools are allowed for this agent
124
126
  const wantsToolCalls = true; // agent toolset may be non-empty
125
127
  try {
@@ -152,6 +154,7 @@ export function registerSessionMessagesRoutes(app: Hono) {
152
154
  content,
153
155
  oneShot: Boolean(body?.oneShot),
154
156
  userContext,
157
+ reasoning,
155
158
  });
156
159
  return c.json({ messageId: assistantMessageId }, 202);
157
160
  } catch (error) {
@@ -22,6 +22,7 @@ type DispatchOptions = {
22
22
  content: string;
23
23
  oneShot?: boolean;
24
24
  userContext?: string;
25
+ reasoning?: boolean;
25
26
  };
26
27
 
27
28
  export async function dispatchAssistantMessage(
@@ -37,6 +38,7 @@ export async function dispatchAssistantMessage(
37
38
  content,
38
39
  oneShot,
39
40
  userContext,
41
+ reasoning,
40
42
  } = options;
41
43
 
42
44
  // DEBUG: Log userContext in dispatch
@@ -108,6 +110,7 @@ export async function dispatchAssistantMessage(
108
110
  projectRoot: cfg.projectRoot,
109
111
  oneShot: Boolean(oneShot),
110
112
  userContext,
113
+ reasoning,
111
114
  },
112
115
  runSessionLoop,
113
116
  );
@@ -298,13 +298,44 @@ async function runAssistant(opts: RunOpts) {
298
298
  let accumulated = '';
299
299
  let stepIndex = 0;
300
300
 
301
+ // Build provider options for reasoning/extended thinking
302
+ const providerOptions: Record<string, unknown> = {};
303
+ const THINKING_BUDGET = 16000;
304
+ // When reasoning is enabled for Anthropic, the API requires max_tokens to fit
305
+ // both thinking tokens AND response tokens. AI SDK adds budgetTokens to maxOutputTokens,
306
+ // so we need to reduce maxOutputTokens to leave room for thinking.
307
+ let effectiveMaxOutputTokens = maxOutputTokens;
308
+
309
+ if (opts.reasoning) {
310
+ if (opts.provider === 'anthropic') {
311
+ providerOptions.anthropic = {
312
+ thinking: { type: 'enabled', budgetTokens: THINKING_BUDGET },
313
+ };
314
+ // Reduce max output to leave room for thinking budget
315
+ if (maxOutputTokens && maxOutputTokens > THINKING_BUDGET) {
316
+ effectiveMaxOutputTokens = maxOutputTokens - THINKING_BUDGET;
317
+ }
318
+ } else if (opts.provider === 'openai') {
319
+ providerOptions.openai = {
320
+ reasoningSummary: 'auto',
321
+ };
322
+ } else if (opts.provider === 'google') {
323
+ providerOptions.google = {
324
+ thinkingConfig: { thinkingBudget: THINKING_BUDGET },
325
+ };
326
+ }
327
+ }
328
+
301
329
  try {
302
330
  const result = streamText({
303
331
  model,
304
332
  tools: toolset,
305
333
  ...(cachedSystem ? { system: cachedSystem } : {}),
306
334
  messages: optimizedMessages,
307
- ...(maxOutputTokens ? { maxOutputTokens } : {}),
335
+ ...(effectiveMaxOutputTokens
336
+ ? { maxOutputTokens: effectiveMaxOutputTokens }
337
+ : {}),
338
+ ...(Object.keys(providerOptions).length > 0 ? { providerOptions } : {}),
308
339
  abortSignal: opts.abortSignal,
309
340
  stopWhen: hasToolCall('finish'),
310
341
  onStepFinish,
@@ -9,6 +9,7 @@ export type RunOpts = {
9
9
  projectRoot: string;
10
10
  oneShot?: boolean;
11
11
  userContext?: string;
12
+ reasoning?: boolean;
12
13
  abortSignal?: AbortSignal;
13
14
  };
14
15