mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
feat: increase max-step of agent
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user