diff --git a/apps/cli/src/application/lib/agent.ts b/apps/cli/src/application/lib/agent.ts index 996e0b8e..4f858b93 100644 --- a/apps/cli/src/application/lib/agent.ts +++ b/apps/cli/src/application/lib/agent.ts @@ -122,12 +122,12 @@ function convertFromMessages(messages: z.infer[]): ModelMessage[ export class AgentNode implements Step { private id: string; - private background: boolean; + private asTool: boolean; private agent: z.infer; - constructor(id: string, background: boolean) { + constructor(id: string, asTool: boolean) { this.id = id; - this.background = background; + this.asTool = asTool; const agentPath = path.join(WorkDir, "agents", `${id}.json`); const agent = fs.readFileSync(agentPath, "utf8"); this.agent = Agent.parse(JSON.parse(agent)); @@ -144,6 +144,9 @@ export class AgentNode implements Step { // tools["ask-human"] = AskHumanTool; // } for (const [name, tool] of Object.entries(this.agent.tools ?? {})) { + if (this.asTool && name === "ask-human") { + continue; + } try { tools[name] = mapAgentTool(tool); } catch (error) { diff --git a/apps/cli/src/application/lib/exec-workflow.ts b/apps/cli/src/application/lib/exec-workflow.ts index 8c7c0ea9..37421665 100644 --- a/apps/cli/src/application/lib/exec-workflow.ts +++ b/apps/cli/src/application/lib/exec-workflow.ts @@ -161,7 +161,7 @@ function loadFunction(id: string) { return func; } -export async function* executeWorkflow(id: string, input: string, interactive: boolean = true): AsyncGenerator, void, unknown> { +export async function* executeWorkflow(id: string, input: string, interactive: boolean = true, asTool: boolean = false): AsyncGenerator, void, unknown> { const runId = runIdGenerator.next(); yield* runFromState({ id, @@ -176,6 +176,7 @@ export async function* executeWorkflow(id: string, input: string, interactive: b pendingToolCallId: null, }, interactive, + asTool, }); } @@ -256,6 +257,7 @@ export async function* resumeWorkflow(runId: string, input: string, interactive: pendingToolCallId, }, interactive, + asTool: false, }); } @@ -264,8 +266,9 @@ async function* runFromState(opts: { runId: string; state: z.infer; interactive: boolean; + asTool: boolean; }) { - const { id, runId, state, interactive } = opts; + const { id, runId, state, interactive, asTool } = opts; let stepIndex = state.stepIndex; let messages = [...state.messages]; let workflow = state.workflow; @@ -288,7 +291,7 @@ async function* runFromState(opts: { while (true) { const step = workflow.steps[stepIndex]; - const node = step.type === "agent" ? new AgentNode(step.id, interactive) : loadFunction(step.id); + const node = step.type === "agent" ? new AgentNode(step.id, asTool) : loadFunction(step.id); yield* ly.logAndYield({ type: "step-start",