Skip to content

Commit

Permalink
feat(agents): allow modification of toolStart options
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Dvorak <toomas2d@gmail.com>
  • Loading branch information
Tomas2D committed Dec 13, 2024
1 parent abb27fe commit 2fd82ef
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/agents/bee/runners/default/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { TokenMemory } from "@/memory/tokenMemory.js";
import { getProp } from "@/internals/helpers/object.js";
import { BaseMemory } from "@/memory/base.js";
import { Cache } from "@/cache/decoratorCache.js";
import { shallowCopy } from "@/serializer/utils.js";

export class DefaultRunner extends BaseRunner {
static {
Expand Down Expand Up @@ -185,24 +186,26 @@ export class DefaultRunner extends BaseRunner {
this.failedAttemptsCounter.use(error);
},
executor: async () => {
const toolOptions = shallowCopy(this.options);

try {
await emitter.emit("toolStart", {
data: {
tool,
input: state.tool_input,
options: this.options,
options: toolOptions,
iteration: state,
},
meta,
});
const toolOutput: ToolOutput = await tool.run(state.tool_input, this.options).context({
const toolOutput: ToolOutput = await tool.run(state.tool_input, toolOptions).context({
[Tool.contextKeys.Memory]: this.memory,
});
await emitter.emit("toolSuccess", {
data: {
tool,
input: state.tool_input,
options: this.options,
options: toolOptions,
result: toolOutput,
iteration: state,
},
Expand All @@ -222,7 +225,7 @@ export class DefaultRunner extends BaseRunner {
data: {
tool,
input: state.tool_input,
options: this.options,
options: toolOptions,
error,
iteration: state,
},
Expand Down

0 comments on commit 2fd82ef

Please sign in to comment.