So there is some data stored in the state that i dont want to be available in the frontend and its way 2 big to be kept going back and forth from the Agent to the Frontend and vise versa.
i was able to clean up the state that is being fetched from the class LangGraphAgent from from copilotkit import LangGraphAgent by over riding the functions get_state() and execute(), but then in frontend im watching the network tab in the dev tools and i noticed the GQL request /api/copilotkit going to the NextJs backend when answering an interrupt is sending these variables:
{
"data": {
"agentSession": {
"agentName": "my_agent",
"nodeName": "some_node_name",
"threadId": "ef76afcc-7016-48ea-b77d-6ff54764981c"
},
"agentStates": [
{
"agentName": "my_agent",
"configurable": "{}",
"state": ".....HERE massive JSON string that includes fields that i dont want to share to the frontend, the reason why its massive"
}
],
"extensions": {},
"forwardedParameters": {},
"frontend": {
"actions": [],
"url": "...."
},
"messages": [],
"metaEvents": [
{
"name": "LangGraphInterruptEvent",
"response": "some answer!",
"value": "Some question"
}
],
"metadata": {
"requestType": "Chat"
},
"runId": null,
"threadId": "ef76afcc-7016-48ea-b77d-6ff54764981c"
},
"properties": {}
}
as you can see in my agent state there is a massive JSON string because of some fields that i dont want them to be there, how can I prevent them from being there?
the reason im looking into this is because sometimes in the remote environment the stream gets reset and looks like the agent disconnected, but regardless of this i still dont want those fields to be there.