mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 12:48:20 +00:00
feat(agent): enable LLM API call retries in AgentHarness
This commit is contained in:
@@ -336,6 +336,49 @@ describe('Sandbox Network isolation integration', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should pass retry configuration to AgentHarness', async () => {
|
||||||
|
const team = await prisma.team.create({
|
||||||
|
data: { name: 'Test Team Retry' },
|
||||||
|
})
|
||||||
|
await prisma.user.create({
|
||||||
|
data: {
|
||||||
|
id: 'test-agent-retry',
|
||||||
|
name: 'Agent Retry',
|
||||||
|
email: 'agent-retry@test.com',
|
||||||
|
type: 'agent',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
await prisma.agent.create({
|
||||||
|
data: {
|
||||||
|
id: 'test-agent-retry',
|
||||||
|
teamId: team.id,
|
||||||
|
type: 'chat',
|
||||||
|
config: { provider: 'google', model: 'gemini' },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const initializeSpy = vi.spyOn(SandboxManager, 'initialize').mockResolvedValue()
|
||||||
|
try {
|
||||||
|
const { harness } = await createAgentSession({
|
||||||
|
teamId: team.id,
|
||||||
|
agentId: 'test-agent-retry',
|
||||||
|
providerName: 'google',
|
||||||
|
modelId: 'gemini',
|
||||||
|
systemPrompt: 'prompt',
|
||||||
|
teamSkills: [],
|
||||||
|
allowedDomains: [],
|
||||||
|
providers: [],
|
||||||
|
maxRetries: 5,
|
||||||
|
baseDelayMs: 1500,
|
||||||
|
})
|
||||||
|
|
||||||
|
// @ts-expect-error accessing private property for verification
|
||||||
|
expect(harness.streamOptions?.maxRetries).toBe(5)
|
||||||
|
} finally {
|
||||||
|
initializeSpy.mockRestore()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
it('should filter out denied tools from AgentHarness', async () => {
|
it('should filter out denied tools from AgentHarness', async () => {
|
||||||
const team = await prisma.team.create({
|
const team = await prisma.team.create({
|
||||||
data: { name: 'Test Team 3' },
|
data: { name: 'Test Team 3' },
|
||||||
|
|||||||
@@ -114,6 +114,8 @@ export interface CreateAgentSessionParams {
|
|||||||
thinkingLevel?: string
|
thinkingLevel?: string
|
||||||
disableTools?: boolean
|
disableTools?: boolean
|
||||||
providers: DbProviderInfo[]
|
providers: DbProviderInfo[]
|
||||||
|
maxRetries?: number
|
||||||
|
baseDelayMs?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createAgentSession(params: CreateAgentSessionParams) {
|
export async function createAgentSession(params: CreateAgentSessionParams) {
|
||||||
@@ -131,6 +133,8 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
|
|||||||
customTools = [],
|
customTools = [],
|
||||||
thinkingLevel,
|
thinkingLevel,
|
||||||
disableTools = false,
|
disableTools = false,
|
||||||
|
maxRetries = 3,
|
||||||
|
baseDelayMs = 2000,
|
||||||
} = params
|
} = params
|
||||||
|
|
||||||
const storage = await DatabaseSessionStorage.create({
|
const storage = await DatabaseSessionStorage.create({
|
||||||
@@ -292,6 +296,10 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
|
|||||||
session,
|
session,
|
||||||
model,
|
model,
|
||||||
thinkingLevel: (thinkingLevel || 'off') as ThinkingLevel,
|
thinkingLevel: (thinkingLevel || 'off') as ThinkingLevel,
|
||||||
|
streamOptions: {
|
||||||
|
maxRetries,
|
||||||
|
maxRetryDelayMs: baseDelayMs,
|
||||||
|
},
|
||||||
systemPrompt: async () => {
|
systemPrompt: async () => {
|
||||||
let prompt = systemPrompt
|
let prompt = systemPrompt
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user