|
@@ -418,6 +418,16 @@ export namespace SessionPrompt {
|
|
|
)
|
|
)
|
|
|
let executionError: Error | undefined
|
|
let executionError: Error | undefined
|
|
|
const taskAgent = await Agent.get(task.agent)
|
|
const taskAgent = await Agent.get(task.agent)
|
|
|
|
|
+ if (!taskAgent) {
|
|
|
|
|
+ const available = await Agent.list().then((agents) => agents.filter((a) => !a.hidden).map((a) => a.name))
|
|
|
|
|
+ const hint = available.length ? ` Available agents: ${available.join(", ")}` : ""
|
|
|
|
|
+ const error = new NamedError.Unknown({ message: `Agent not found: "${task.agent}".${hint}` })
|
|
|
|
|
+ Bus.publish(Session.Event.Error, {
|
|
|
|
|
+ sessionID,
|
|
|
|
|
+ error: error.toObject(),
|
|
|
|
|
+ })
|
|
|
|
|
+ throw error
|
|
|
|
|
+ }
|
|
|
const taskCtx: Tool.Context = {
|
|
const taskCtx: Tool.Context = {
|
|
|
agent: task.agent,
|
|
agent: task.agent,
|
|
|
messageID: assistantMessage.id,
|
|
messageID: assistantMessage.id,
|
|
@@ -560,6 +570,16 @@ export namespace SessionPrompt {
|
|
|
|
|
|
|
|
// normal processing
|
|
// normal processing
|
|
|
const agent = await Agent.get(lastUser.agent)
|
|
const agent = await Agent.get(lastUser.agent)
|
|
|
|
|
+ if (!agent) {
|
|
|
|
|
+ const available = await Agent.list().then((agents) => agents.filter((a) => !a.hidden).map((a) => a.name))
|
|
|
|
|
+ const hint = available.length ? ` Available agents: ${available.join(", ")}` : ""
|
|
|
|
|
+ const error = new NamedError.Unknown({ message: `Agent not found: "${lastUser.agent}".${hint}` })
|
|
|
|
|
+ Bus.publish(Session.Event.Error, {
|
|
|
|
|
+ sessionID,
|
|
|
|
|
+ error: error.toObject(),
|
|
|
|
|
+ })
|
|
|
|
|
+ throw error
|
|
|
|
|
+ }
|
|
|
const maxSteps = agent.steps ?? Infinity
|
|
const maxSteps = agent.steps ?? Infinity
|
|
|
const isLastStep = step >= maxSteps
|
|
const isLastStep = step >= maxSteps
|
|
|
msgs = await insertReminders({
|
|
msgs = await insertReminders({
|
|
@@ -964,7 +984,18 @@ export namespace SessionPrompt {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function createUserMessage(input: PromptInput) {
|
|
async function createUserMessage(input: PromptInput) {
|
|
|
- const agent = await Agent.get(input.agent ?? (await Agent.defaultAgent()))
|
|
|
|
|
|
|
+ const agentName = input.agent || (await Agent.defaultAgent())
|
|
|
|
|
+ const agent = await Agent.get(agentName)
|
|
|
|
|
+ if (!agent) {
|
|
|
|
|
+ const available = await Agent.list().then((agents) => agents.filter((a) => !a.hidden).map((a) => a.name))
|
|
|
|
|
+ const hint = available.length ? ` Available agents: ${available.join(", ")}` : ""
|
|
|
|
|
+ const error = new NamedError.Unknown({ message: `Agent not found: "${agentName}".${hint}` })
|
|
|
|
|
+ Bus.publish(Session.Event.Error, {
|
|
|
|
|
+ sessionID: input.sessionID,
|
|
|
|
|
+ error: error.toObject(),
|
|
|
|
|
+ })
|
|
|
|
|
+ throw error
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
const model = input.model ?? agent.model ?? (await lastModel(input.sessionID))
|
|
const model = input.model ?? agent.model ?? (await lastModel(input.sessionID))
|
|
|
const full =
|
|
const full =
|
|
@@ -1531,6 +1562,16 @@ NOTE: At any point in time through this workflow you should feel free to ask the
|
|
|
await SessionRevert.cleanup(session)
|
|
await SessionRevert.cleanup(session)
|
|
|
}
|
|
}
|
|
|
const agent = await Agent.get(input.agent)
|
|
const agent = await Agent.get(input.agent)
|
|
|
|
|
+ if (!agent) {
|
|
|
|
|
+ const available = await Agent.list().then((agents) => agents.filter((a) => !a.hidden).map((a) => a.name))
|
|
|
|
|
+ const hint = available.length ? ` Available agents: ${available.join(", ")}` : ""
|
|
|
|
|
+ const error = new NamedError.Unknown({ message: `Agent not found: "${input.agent}".${hint}` })
|
|
|
|
|
+ Bus.publish(Session.Event.Error, {
|
|
|
|
|
+ sessionID: input.sessionID,
|
|
|
|
|
+ error: error.toObject(),
|
|
|
|
|
+ })
|
|
|
|
|
+ throw error
|
|
|
|
|
+ }
|
|
|
const model = input.model ?? agent.model ?? (await lastModel(input.sessionID))
|
|
const model = input.model ?? agent.model ?? (await lastModel(input.sessionID))
|
|
|
const userMsg: MessageV2.User = {
|
|
const userMsg: MessageV2.User = {
|
|
|
id: MessageID.ascending(),
|
|
id: MessageID.ascending(),
|
|
@@ -1783,7 +1824,14 @@ NOTE: At any point in time through this workflow you should feel free to ask the
|
|
|
log.info("command", input)
|
|
log.info("command", input)
|
|
|
const command = await Command.get(input.command)
|
|
const command = await Command.get(input.command)
|
|
|
if (!command) {
|
|
if (!command) {
|
|
|
- throw new NamedError.Unknown({ message: `Command not found: "${input.command}"` })
|
|
|
|
|
|
|
+ const available = await Command.list().then((cmds) => cmds.map((c) => c.name))
|
|
|
|
|
+ const hint = available.length ? ` Available commands: ${available.join(", ")}` : ""
|
|
|
|
|
+ const error = new NamedError.Unknown({ message: `Command not found: "${input.command}".${hint}` })
|
|
|
|
|
+ Bus.publish(Session.Event.Error, {
|
|
|
|
|
+ sessionID: input.sessionID,
|
|
|
|
|
+ error: error.toObject(),
|
|
|
|
|
+ })
|
|
|
|
|
+ throw error
|
|
|
}
|
|
}
|
|
|
const agentName = command.agent ?? input.agent ?? (await Agent.defaultAgent())
|
|
const agentName = command.agent ?? input.agent ?? (await Agent.defaultAgent())
|
|
|
|
|
|