Reading current prompt within Tool code #464
-
|
Hi there, how would I go about accessing the current prompt from inside a tool? One of the tools I've got sends an email out with the conversation history thus far, but I'm not sure how to access said history within my tool so I can add it to the email content. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Hi @samDobsonDev ! Thanks for your question and sorry for our delay in the answer! Currently there's no direct way to get the prompt from inside the tool call, but you can workaround this using
That's a bit a hacky (yet working) way to do that, but initially Koog wasn't designed for the intent of exposing the message history or prompt to the tools. Hope this helps! Also it would be really interesting to learn more about your use case so that we can adapt better to it in the future :) Cheers! |
Beta Was this translation helpful? Give feedback.
-
|
Yeah, so one of the tools I'm designing hands a user over to a human when requested, like if the AI agent is unable to address the user's query or if the user explicitly asks for it. This handover is just an email that we send to the human agent with user information etc. Another thing I need to add to the email body is the conversation history up to that point, so that the human agent has more context of the problem that the user is facing. |
Beta Was this translation helpful? Give feedback.
-
|
Also I forgot the |
Beta Was this translation helpful? Give feedback.
Hi @samDobsonDev ! Thanks for your question and sorry for our delay in the answer!
Currently there's no direct way to get the prompt from inside the tool call, but you can workaround this using
Persistencyfeature (see https://docs.koog.ai/agent-persistency/ ) like this:ToolSetclass so that it would hold thePersistencyStorageProvider(from thePersistencyfeature) that contains the latest saved full message history of your agent, and define all your tools inside.For example, your
sendEmailtool could be similar to this: