Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sending the messages array to a tool's execute function #3468

Open
mauricekleine opened this issue Nov 4, 2024 · 1 comment
Open
Labels
ai/core enhancement New feature or request

Comments

@mauricekleine
Copy link

mauricekleine commented Nov 4, 2024

Feature Description

I'm using LLMs as tools for a generic task agent that delegates tasks to tools. In order for each LLM tool to have access to the context of the agent execution chain, it would be great if each tool has access to the messages array so far. So let's say I set maxSteps to 5, then the initial call to my streamText method would contain the original messages array send by useChat. It would then determine which tool to use (toolChoice is set to true) and execute that tool - which in my case is another LLM call with it's own prompt:

export const myTool = tool({
    description: '',
    execute: async ({ description, title }) => {
        const result = await generateText({
            description, '',
	    messages , // <== this is currently missing
	    model: vertex,
	    system: '',
        });

         return { text: result.text };
    },
    parameters: z.object({ ... })
});

But the context of the message history between tools gets lost since the tools don't have access to the messages array, including the results of previous tool executions.

Use Case

No response

Additional context

No response

@lgrammel lgrammel added enhancement New feature or request ai/core labels Nov 4, 2024
@Slyracoon23
Copy link

This would be extremely useful +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/core enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants