feat: increase max-step of agent

This commit is contained in:
Acbox
2026-01-17 13:12:49 +08:00
parent 52731b9fa1
commit 65e03f0b1e
4 changed files with 13 additions and 4 deletions
+2 -1
View File
@@ -115,6 +115,7 @@ export const createAgent = (params: AgentParams) => {
model: gateway,
system: getSystemPrompt(),
messages,
stopWhen: stepCountIs(50),
tools: await getTools(),
onFinish: async () => {
await onComplete()
@@ -142,7 +143,7 @@ export const createAgent = (params: AgentParams) => {
system: getSystemPrompt(),
}
},
stopWhen: stepCountIs(10),
stopWhen: stepCountIs(50),
messages,
tools: await getTools(),
onFinish: async () => {
+8 -2
View File
@@ -58,15 +58,21 @@ export const agentModule = new Elysia({
try {
const encoder = new TextEncoder()
console.log('📨 Starting agent stream for message:', body.message.substring(0, 50))
console.log('📨 [API] Starting agent stream for message:', body.message.substring(0, 50))
console.log('🔗 [API] Starting event loop...')
let eventCount = 0
// Send events as they come
for await (const event of agent.ask(body.message)) {
eventCount++
console.log(`📤 [API] Received event #${eventCount}, type:`, event.type)
const data = JSON.stringify(event)
console.log(`📤 [API] Enqueueing event #${eventCount}...`)
controller.enqueue(encoder.encode(`data: ${data}\n\n`))
console.log(`✅ [API] Event #${eventCount} enqueued successfully`)
}
console.log('✅ Agent stream completed successfully')
console.log(`✅ [API] Agent stream completed successfully (${eventCount} events)`)
// Send done event
controller.enqueue(encoder.encode('data: [DONE]\n\n'))
@@ -49,6 +49,7 @@ export async function createAgent(params: CreateAgentStreamParams) {
// Ensure container is running before creating agent
const container = useContainer(containerInfo.containerName, {
namespace: containerInfo.namespace,
socket: process.env.CONTAINERD_SOCKET,
})
// Check and start container if not running
+2 -1
View File
@@ -179,7 +179,8 @@ export function useContainer(
buildExecCommand(command: string[]): string[] {
// nerdctl exec with -i to keep STDIN open for MCP servers
return [...client.nerdctlCommand, 'exec', '-i', containerName, ...command]
const socket = options?.socket ? ['--address', options.socket] : []
return [...client.nerdctlCommand, ...socket, 'exec', '-i', containerName, ...command]
}
}
}