Please add support for sending custom delta events from the tool execute function when the loop runs in stream. Right now it is possible only with a hack. It will be nice to have it built-in.
const agent = new Agent({
name: 'agent',
tools: [tool({
name: "mytool",
execute: async (args, runContext, {toolCall}) => {
const generator = getLongGenerator();
for await (let event of result) {
if (runContext.context.result && !runContext.context.result.cancelled) {
runContext.context.result._addItem({name: 'custom_event', item: event, type: 'run_item_stream_event'});
}
}
}
})]
});
const runnerOptions = {context: {}, stream: true};
const result = await run(agent, prompt, runnerOptions);
runnerOptions.context.result = result;
for await (let event of result) {
yield event; //combined original and custom events
}
await result.completed;
Such custom events doesn't enter into the run history. They are transparent for state.
Please read this first
Describe the feature
Please add support for sending custom delta events from the tool execute function when the loop runs in stream. Right now it is possible only with a hack. It will be nice to have it built-in.
Such custom events doesn't enter into the run history. They are transparent for state.