Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d98c89b
feat: add request handler
aleskalfas Jun 16, 2025
5e3a51d
fixup!
aleskalfas Jun 16, 2025
60a72ed
fixup!
aleskalfas Jun 16, 2025
8b0e303
feat: problem decomposer
aleskalfas Jun 16, 2025
22e4a48
feat: add agent config creator
aleskalfas Jun 16, 2025
5274314
feat: agent config creator prompt improvements
aleskalfas Jun 16, 2025
4350517
feat: introduce laml
aleskalfas Jun 16, 2025
d9a6ba6
feat: in progress
aleskalfas Jun 16, 2025
0899b46
feat: laml result typing
aleskalfas Jun 16, 2025
1d1f2d8
feat: result typing improvement
aleskalfas Jun 16, 2025
15aa3c0
feat: initial composed prompt
aleskalfas Jun 16, 2025
1ab5504
feat: task config initializer under construction
aleskalfas Jun 16, 2025
aecbb69
chore: supervisor workflow reorganization
aleskalfas Jun 16, 2025
aa1eeff
feat: test matrix general
aleskalfas Jun 16, 2025
0fffc11
fixup!
aleskalfas Jun 16, 2025
014121b
feat: stabilize test matrix
aleskalfas Jun 16, 2025
d3134bb
feat(supervisor workflow): refactoring llm calls
aleskalfas Jun 16, 2025
8411961
chore: under construction
aleskalfas Jun 16, 2025
51d4938
feat: problem decomposer updated system prompt
aleskalfas Jun 16, 2025
3f5fbdf
feat: in progress
aleskalfas Jun 16, 2025
efb07c0
feat: tune problem decomposer step system prompt
aleskalfas Jun 16, 2025
a783eb4
feat: under construction
aleskalfas Jun 16, 2025
506b306
feat: add retry mechanism to correct llm response
aleskalfas Jun 16, 2025
7b5c102
feat: agent config initializer select only mode
aleskalfas Jun 16, 2025
a2042b6
feat: working workflow with big LLM
aleskalfas Jun 16, 2025
0e64f12
feat: add missing inputs response into problem decomposer
aleskalfas Jun 16, 2025
5554da2
feat: add edge cases examples to task initializer steps
aleskalfas Jun 16, 2025
e56cc08
feat: working workflow with small models
aleskalfas Jun 16, 2025
ed9ac79
feat: enrich the agent's instruction format
aleskalfas Jun 16, 2025
5ba012d
feat: improving agents response format
aleskalfas Jun 16, 2025
161b064
feat: ascii style
aleskalfas Jun 16, 2025
01632a8
feat: add memory to the supervisor workflow
aleskalfas Jun 16, 2025
4a25ea5
chore: format
aleskalfas Jun 16, 2025
da50b41
fix: multiple input focus
aleskalfas Jun 16, 2025
29161eb
chore: rename boss to beekeeper
aleskalfas Jun 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ WATSONX_CHAT_MODEL_OPERATOR="ibm/granite-3-3-8b-instruct"
BEE_FRAMEWORK_LOG_PRETTY=false
BEE_FRAMEWORK_LOG_LEVEL="debug"
BEE_FRAMEWORK_LOG_SINGLE_LINE="false"

# Development only
DEV_SUPERVISOR_WORKFLOW_ENABLED=true
DEV_SUPERVISOR_WORKFLOW_DISABLE_EXAMPLES=false
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"ui:test:chat": "tsx --inspect --no-warnings examples/ui/chat-monitor/chat-monitor.js",
"ui:test": "tsx --inspect --no-warnings examples/ui/chat-monitor/input/input.js",
"ts:check": "tsc --noEmit --project tsconfig.json",
"build": "rimraf dist && tsc -b && tsc-alias",
"clean": "rimraf dist",
"build": "npm run clean && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
"lint": "eslint",
"lint:fix": "eslint --fix",
"format": "prettier --check .",
Expand Down Expand Up @@ -100,8 +101,9 @@
"@types/eslint-config-prettier": "^6.11.3",
"@types/eslint__js": "^8.42.3",
"@types/node": "^18.15.3",
"beeai-framework": "0.1.14",
"beeai-framework": "0.1.16",
"cross-env": "^7.0.3",
"date-fns": "^4.1.0",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"husky": "^9.1.6",
Expand All @@ -122,6 +124,6 @@
"@ai-sdk/openai": "^1.1.14",
"@eslint/js": "^9.21.0",
"@i-am-bee/acp-sdk": "0.0.4",
"beeai-framework": "0.1.14"
"beeai-framework": "0.1.16"
}
}
50 changes: 31 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 48 additions & 38 deletions src/agents/agent-factory.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
import { BaseToolsFactory } from "@/base/tools-factory.js";
import { getChatLLM } from "@/helpers/llm.js";
import { Switches } from "@/runtime/factory.js";
import { TaskRunIdValue } from "@/tasks/manager/dto.js";
import { ReActAgent } from "beeai-framework/agents/react/agent";
import { AssistantMessage, ToolMessage } from "beeai-framework/backend/message";
import { TokenMemory } from "beeai-framework/memory/tokenMemory";
import { UnconstrainedMemory } from "beeai-framework/memory/unconstrainedMemory";
import { BaseAgentFactory, CreateAgentInput } from "./base/agent-factory.js";
import { supervisor } from "./index.js";
import { AssistantMessage, ToolMessage } from "beeai-framework/backend/message";
import { SupervisorWorkflow } from "./supervisor-workflow/supervisor-workflow.js";

export type AgentUpdateCallback = (key: string, value: string) => void;

export class AgentFactory extends BaseAgentFactory<ReActAgent> {
export class AgentFactory extends BaseAgentFactory<
ReActAgent | SupervisorWorkflow
> {
createAgent<TCreateInput extends CreateAgentInput = CreateAgentInput>(
input: TCreateInput,
toolsFactory: BaseToolsFactory,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
switches?: Switches,
) {
const llm = getChatLLM(input.agentKind);
const generalInstructions = `You are a ${input.agentKind} kind of agent (agentId=${input.agentId}, agentType=${input.agentType}). ${input.instructions}`;
switch (input.agentKind) {
case "supervisor": {
const tools = toolsFactory.createTools(input.tools);
// const tools = toolsFactory.createTools(input.tools);
// return new ReActAgent({
// meta: {
// name: input.agentId,
// description: input.description,
// },
// llm,
// memory: new UnconstrainedMemory(),
// tools,
// templates: {
// system: (template) =>
// template.fork((config) => {
// config.defaults.instructions =
// supervisor.SUPERVISOR_INSTRUCTIONS(input.agentId, switches);
// }),
// },
// execution: {
// maxIterations: 100,
// maxRetriesPerStep: 2,
// totalMaxRetries: 10,
// },
// });

return new ReActAgent({
meta: {
name: input.agentId,
description: input.description,
},
llm,
memory: new UnconstrainedMemory(),
tools,
templates: {
system: (template) =>
template.fork((config) => {
config.defaults.instructions =
supervisor.SUPERVISOR_INSTRUCTIONS(input.agentId, switches);
}),
},
execution: {
maxIterations: 100,
maxRetriesPerStep: 2,
totalMaxRetries: 10,
},
});
return new SupervisorWorkflow(this.logger, llm, input.agentId);
}
case "operator":
return new ReActAgent({
Expand Down Expand Up @@ -69,25 +75,29 @@ export class AgentFactory extends BaseAgentFactory<ReActAgent> {
}

async runAgent(
agent: ReActAgent,
agent: ReActAgent | SupervisorWorkflow,
prompt: string,
onUpdate: (key: string, value: string) => void,
onUpdate: AgentUpdateCallback,
signal: AbortSignal,
taskRunId: TaskRunIdValue,
addToMemory?: (AssistantMessage | ToolMessage)[],
): Promise<string> {
if (addToMemory) {
agent.memory.addMany(addToMemory);
}
if (agent instanceof SupervisorWorkflow) {
return await agent.run({ prompt, onUpdate, originTaskRunId: taskRunId });
} else {
const resp = await agent
.run({ prompt }, { signal })
.observe((emitter) => {
emitter.on("update", async ({ update }) => {
onUpdate(update.key, update.value);
});
})
.context({ task_run_signal: signal });

const resp = await agent
.run({ prompt }, { signal })
.observe((emitter) => {
emitter.on("update", async ({ update }) => {
onUpdate(update.key, update.value);
});
})
.context({ task_run_signal: signal });

return resp.result.text;
return resp.result.text;
}
}
}
9 changes: 9 additions & 0 deletions src/agents/base/agent-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { BaseToolsFactory } from "@/base/tools-factory.js";
import { Switches } from "@/runtime/factory.js";
import { AssistantMessage, ToolMessage } from "beeai-framework/backend/message";
import { AgentKindEnum } from "../registry/dto.js";
import { Logger } from "beeai-framework";
import { TaskRunIdValue } from "@/tasks/manager/dto.js";

export interface CreateAgentInput {
agentKind: AgentKindEnum;
Expand All @@ -13,6 +15,12 @@ export interface CreateAgentInput {
}

export abstract class BaseAgentFactory<TAgent> {
protected logger: Logger;
constructor(logger: Logger) {
this.logger = logger.child({
name: this.constructor.name,
});
}
abstract createAgent(
input: CreateAgentInput,
toolsFactory: BaseToolsFactory,
Expand All @@ -23,6 +31,7 @@ export abstract class BaseAgentFactory<TAgent> {
prompt: string,
onUpdate: (key: string, value: string) => void,
signal: AbortSignal,
taskRunId: TaskRunIdValue,
addToMemory?: (AssistantMessage | ToolMessage)[],
): Promise<string>;
}
Loading