I’d like to save the session rid of AIP agent in workshop and tie it to a given object so that I can later reload that session. The reloading part works well: if I manually put my session rid in the object’s property, the session gets loaded just fine. However I can’t figure out how to save that variable back onto the object. I’m probably missing something very stupid, but still, I looked for:
ways to get the Agent itself to update the session on the object: not possible as we’re not allowed to pass the variable used to store the session rid as an argument to the agent itself
using a custom widget to trigger the update of the object when the variable changes. Unfortunately the custom widget can only trigger events and not actions. Here there is the option of using OSDK and updating the value through that way, but it feel horribly complicated for something that seems like it should be rather simple.
A solution might be to have a button the user would have to click on and trigger the action to update the object, I guess I could sell it as “if you really care about that session, you won’t mind clicking on that button, otherwise you will lose it”, but I’d rather this be done automatically.
So I really wonder, have people managed to use this property in any way ? Am I not looking at it from the right angle ? All I want is to be able to tie an object to a session and reopen said session when the object is selected.
ways to get the Agent itself to update the session on the object: not possible as we’re not allowed to pass the variable used to store the session rid as an argument to the agent itself
There’s no reason why you shouldn’t be able to do this! You can provide the variable you map to the session identifier variable as context to the agent. Just make sure the agent doesn’t try to update this variable itself otherwise it could end up creating a new session.
For 2 and 3, you are right. We’ve seen people do 3 before, but agreed this is clunky.
To shed some light on the intentions of this variable. We wanted to provide users the ability to auto create a new session based on other interactions within the workshop module. If you set the variable to be undefined or the empty string, the current session will be replaced with a new session. The other use case we wanted to support was linking out to a specific session based on a URL parameter in the workshop module, which you can do with the active session identifier variable. This was useful for reopening sessions created by an automate triggering an agent / agents running as functions elsewhere in Foundry.
The functionality you are building is something we are interested in supporting in a first-class way. The idea we had for this was to store a mapping of arbitrary id to session id such that you can replace session history with a “session history variable” that just represents an id for a session. Then we perform getOrCreate with that arbitrary id (in this case just an objectRid) so you always have a unique session per id. Would this feature help you?
for 1. I don’t think this is actually possible at the moment: I’m not able to select the string variable in which I’m storing the session id back as a parameter to the agent: it just doesn’t show up in the dropdown list of variables I can give the agent. I’m also not sure this would actually work in the end, since the agent sets the value itself which means that in the case of a new session, the value would be null, and then eventually set to something once we start talking to the agent, and that means we’d need to make sure the agent stores the updated value of the variable and not the initial (null) value.
I don’t think that at the moment it’s possible to create a new session with an arbitrary string: if I put an arbitrary string in the session variable, as soon as I start talking to the agent, this value gets overridden with a session ID. if I then try to override it manually and set it to the original value, well, there is no session to recover, since the discussion with the Agent had not started at the time I put my original value: it only started when the session id overrode my value.
So I think this is what happens:
put “test” in the session variable”
ask a question to the agent
the agent immediately replaced the session variable with a RID
manually put “test” back in the session variable
there is nothing to load since the session I started talking into is now tied to the RID above.
The solution you’re suggesting sounds like it would do what I’d like to happen, so I’d love to try it out ! it would also be super helpful to have the ability to trigger an action when a new session is created (if this was possible, then I’d be able to do everything I want right now: I’d just update my object’s property with the session id when the trigger would fire).
For now, I’m using the “save session” button solution. It’s not amazing but it works, I just have to be cautious about how I update my object.
Try creating the variable from the agent list of variables rather than directly in the session identifier variable drop down. This should be possible as you can see from the screenshot below.
You’d need to provide the agent with an action it can use to write the sessionRid variable you provide as input to an object. Then you could use some prompting: “on the first message of the session, call the “save session” action”.
It is not currently possible to create a session with an arbitrary string, this is something we are discussing as a potential feature to help this workflow.