fix(ai): increase default tool rounds

This commit is contained in:
digua committed 2026-06-05 11:12:42 +08:00
1 parent 9b1f359699
commit 31f3c610ce
8 files changed
+19 -5

No files matched your search

+2 -1
View File
@@ -6,6 +6,7 @@
*/
import {
DEFAULT_MAX_TOOL_ROUNDS,
runAgentCore,
checkAndCompress,
buildSystemPrompt,
@@ -170,7 +171,7 @@ export async function runServerAgent(options: RunAgentOptions): Promise<void> {
tools,
history,
userMessage,
maxToolRounds: 5,
maxToolRounds: DEFAULT_MAX_TOOL_ROUNDS,
abortSignal,
steerMessage,
thinkingLevel: thinkingLevel as import('@openchatlab/core').ThinkingLevel | undefined,
+2 -1
View File
@@ -10,6 +10,7 @@ import { getHistoryForAgent, setPendingDebugContext } from '../conversations'
import { aiLogger, isDebugMode } from '../logger'
import { t as i18nT } from '../../i18n'
import {
DEFAULT_MAX_TOOL_ROUNDS,
runAgentCore,
streamSimple,
type PiMessage,
@@ -63,7 +64,7 @@ export class Agent {
this.skillCtx = skillCtx
this.locale = locale
this.config = {
maxToolRounds: config.maxToolRounds ?? 5,
maxToolRounds: config.maxToolRounds ?? DEFAULT_MAX_TOOL_ROUNDS,
thinkingLevel: config.thinkingLevel,
}
}
@@ -0,0 +1,9 @@
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { DEFAULT_MAX_TOOL_ROUNDS } from '../constants'
describe('Agent defaults', () => {
it('uses 10 tool rounds by default', () => {
assert.equal(DEFAULT_MAX_TOOL_ROUNDS, 10)
})
})
@@ -0,0 +1 @@
export const DEFAULT_MAX_TOOL_ROUNDS = 10
+2 -1
View File
@@ -17,6 +17,7 @@ import { StreamingThinkTagParser, needsStreamingThinkParsing } from '@openchatla
import type { AgentCoreOptions, AgentCoreResult, AgentTokenUsage, SimpleHistoryMessage } from './types'
import { initTokenizer } from '../tokenizer'
import { DEFAULT_MAX_TOOL_ROUNDS } from './constants'
function createEmptyPiUsage(): PiUsage {
return {
@@ -63,7 +64,7 @@ export async function runAgentCore(options: AgentCoreOptions): Promise<AgentCore
tools,
history,
userMessage,
maxToolRounds = 5,
maxToolRounds = DEFAULT_MAX_TOOL_ROUNDS,
abortSignal,
steerMessage = 'Please provide your final answer based on the information gathered.',
onEvent,
@@ -1,2 +1,3 @@
export type { AgentCoreOptions, AgentCoreEvent, AgentCoreResult, AgentTokenUsage, SimpleHistoryMessage } from './types'
export { runAgentCore } from './core'
export { DEFAULT_MAX_TOOL_ROUNDS } from './constants'
+1 -1
View File
@@ -104,7 +104,7 @@ export type { PreprocessingPipelineOptions, PreprocessingPipelineResult } from '
// Agent Core
export type { AgentCoreOptions, AgentCoreEvent, AgentCoreResult, AgentTokenUsage, SimpleHistoryMessage } from './agent'
export { runAgentCore } from './agent'
export { DEFAULT_MAX_TOOL_ROUNDS, runAgentCore } from './agent'
// Agent Event Handler
export { AgentEventHandler, estimateTokensFromText } from './agent/event-handler'
+1 -1
View File
@@ -196,7 +196,7 @@ export type {
// Agent Core
export type { AgentCoreOptions, AgentCoreEvent, AgentCoreResult, AgentTokenUsage, SimpleHistoryMessage } from './ai'
export { runAgentCore } from './ai'
export { DEFAULT_MAX_TOOL_ROUNDS, runAgentCore } from './ai'
// Summary generation
export {