Skip to content

Commit 81ef168

Browse files
authored
feat: allow set reasoningEffort in AIAgentArgs (#3241)
## Description This PR adds an optional `reasoningEffort` setting to AI Agent arguments so GPT-5 model calls can control reasoning effort per agent configuration. ## Context GPT-5 requests previously used a fixed reasoning effort. Exposing this setting lets consumers tune inference behavior while keeping a default value when no explicit effort is provided. ## Approach taken / Explain the design - Added a shared `ReasoningEffort` enum to `@botonic/core` and exposed it through `AiAgentBaseArgs`. - Propagated `reasoningEffort` from the AI Agents plugin into `LLMConfig` for both specialist and router agents. - Updated GPT-5 model settings to use the provided effort, defaulting to `medium`; non-GPT-5 fallback settings continue using `none`. - Bumped `@botonic/plugin-core` to `0.51.1` and `@botonic/plugin-ai-agents` to `0.51.1`. ## Testing The pull request has unit test coverage for the default GPT-5 reasoning effort in `LLMConfig`.
1 parent 3ed5a64 commit 81ef168

7 files changed

Lines changed: 38 additions & 17 deletions

File tree

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/botonic-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@botonic/core",
3-
"version": "0.51.0",
3+
"version": "0.51.1",
44
"license": "MIT",
55
"description": "Build Chatbots using React",
66
"main": "./lib/cjs/index.js",

packages/botonic-core/src/models/ai-agents.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ export enum VerbosityLevel {
116116
High = 'high',
117117
}
118118

119+
export enum ReasoningEffort {
120+
None = 'none',
121+
Low = 'low',
122+
Medium = 'medium',
123+
High = 'high',
124+
}
125+
119126
export interface HubtypeAssistantMessage {
120127
role: 'assistant'
121128
content: string
@@ -139,6 +146,7 @@ export type AiAgentBaseArgs = {
139146
instructions: string
140147
model: string
141148
verbosity: VerbosityLevel
149+
reasoningEffort?: ReasoningEffort
142150
inputGuardrailRules?: GuardrailRule[]
143151
previousHubtypeMessages?: HubtypeAssistantMessage[]
144152
outputMessagesSchemas?: z.ZodObject<any>[]

packages/botonic-plugin-ai-agents/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@botonic/plugin-ai-agents",
3-
"version": "0.51.0",
3+
"version": "0.51.1",
44
"main": "./lib/cjs/index.js",
55
"module": "./lib/esm/index.js",
66
"description": "Use AI Agents to generate your contents",
@@ -14,7 +14,7 @@
1414
"format": "biome format --write src/ tests/"
1515
},
1616
"dependencies": {
17-
"@botonic/core": "^0.51.0",
17+
"@botonic/core": "^0.51.1",
1818
"@openai/agents": "^0.10.1",
1919
"axios": "^1.15.2",
2020
"openai": "^6.36.0",

packages/botonic-plugin-ai-agents/src/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
type BotContext,
77
type HubtypeAssistantMessage,
88
type Plugin,
9+
type ReasoningEffort,
910
type ResolvedPlugins,
1011
} from '@botonic/core'
1112
import { handoff, setTracingDisabled, tool } from '@openai/agents'
@@ -86,6 +87,8 @@ export default class BotonicPluginAiAgents<
8687
throw new Error('Auth token is required')
8788
}
8889

90+
const reasoningEffort = aiAgentArgs.reasoningEffort
91+
8992
const inferenceId = uuidv7()
9093

9194
try {
@@ -94,7 +97,8 @@ export default class BotonicPluginAiAgents<
9497
botContext,
9598
aiAgentArgs,
9699
authToken,
97-
inferenceId
100+
inferenceId,
101+
reasoningEffort
98102
)
99103
}
100104

@@ -103,7 +107,8 @@ export default class BotonicPluginAiAgents<
103107
botContext,
104108
aiAgentArgs,
105109
authToken,
106-
inferenceId
110+
inferenceId,
111+
reasoningEffort
107112
)
108113
}
109114

@@ -130,14 +135,16 @@ export default class BotonicPluginAiAgents<
130135
botContext: BotContext<TPlugins, TExtraData>,
131136
aiAgentArgs: AiAgentSpecialistArgs,
132137
authToken: string,
133-
inferenceId: string
138+
inferenceId: string,
139+
reasoningEffort?: ReasoningEffort
134140
) {
135141
const llmConfig = new LLMConfig({
136142
maxRetries: this.maxRetries,
137143
timeout: this.timeout,
138144
modelName: aiAgentArgs.model,
139145
verbosity: aiAgentArgs.verbosity,
140146
botContext,
147+
reasoningEffort,
141148
})
142149

143150
// Get LLM config, tools and agent
@@ -190,7 +197,8 @@ export default class BotonicPluginAiAgents<
190197
botContext: BotContext<TPlugins, TExtraData>,
191198
aiAgentArgs: AIAgentRouterArgs,
192199
authToken: string,
193-
inferenceId: string
200+
inferenceId: string,
201+
reasoningEffort?: ReasoningEffort
194202
) {
195203
const { specialists, name, instructions } = aiAgentArgs
196204

@@ -200,6 +208,7 @@ export default class BotonicPluginAiAgents<
200208
modelName: aiAgentArgs.model,
201209
verbosity: aiAgentArgs.verbosity,
202210
botContext,
211+
reasoningEffort,
203212
})
204213

205214
const specialistsAgents = await Promise.all(

packages/botonic-plugin-ai-agents/src/llm-config.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { BotContext, VerbosityLevel } from '@botonic/core'
1+
import { type BotContext, ReasoningEffort, VerbosityLevel } from '@botonic/core'
22
import {
33
type Model,
44
type ModelProvider,
@@ -24,6 +24,7 @@ export interface LLMConfigParams {
2424
modelName: string
2525
verbosity: VerbosityLevel
2626
botContext: BotContext
27+
reasoningEffort?: ReasoningEffort
2728
}
2829

2930
export class LLMConfig {
@@ -33,13 +34,15 @@ export class LLMConfig {
3334
public readonly modelName: string
3435
public readonly modelSettings: ModelSettings
3536
public readonly modelProvider: ModelProvider
37+
public readonly reasoningEffort?: ReasoningEffort
3638

3739
constructor({
3840
maxRetries,
3941
timeout,
4042
modelName,
4143
verbosity,
4244
botContext,
45+
reasoningEffort,
4346
}: LLMConfigParams) {
4447
this.maxRetries = maxRetries
4548
this.timeout = timeout
@@ -48,6 +51,7 @@ export class LLMConfig {
4851
LLM_PROVIDER === LLM_PROVIDERS.OPENAI ? LLM_OPENAI_MODEL : modelName
4952
this.modelProvider = this.getModelProvider()
5053
this.modelSettings = this.getModelSettings(modelName, verbosity)
54+
this.reasoningEffort = reasoningEffort
5155
}
5256

5357
async getModel(): Promise<Model> {
@@ -141,7 +145,7 @@ export class LLMConfig {
141145
): ModelSettings {
142146
if (model.includes('gpt-5')) {
143147
return {
144-
reasoning: { effort: 'none' },
148+
reasoning: { effort: this.reasoningEffort ?? ReasoningEffort.Medium },
145149
temperature: 1,
146150
text: { verbosity },
147151
}
@@ -150,13 +154,13 @@ export class LLMConfig {
150154
if (model.includes('gpt-4')) {
151155
return {
152156
temperature: 0,
153-
text: { verbosity: 'medium' },
157+
text: { verbosity: VerbosityLevel.Medium },
154158
}
155159
}
156160

157161
// LiteLLM can proxy any model — fall back to reasoning settings
158162
return {
159-
reasoning: { effort: 'none' },
163+
reasoning: { effort: ReasoningEffort.None },
160164
temperature: 1,
161165
text: { verbosity },
162166
}

packages/botonic-plugin-ai-agents/tests/llm-config.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ describe('LLMConfig', () => {
150150
})
151151

152152
expect(config.modelSettings).toEqual({
153-
reasoning: { effort: 'none' },
153+
reasoning: { effort: 'medium' },
154154
temperature: 1,
155155
text: { verbosity: 'high' },
156156
})

0 commit comments

Comments
 (0)