Hey everyone, I ran into a weird issue when deploying a CopilotKit-based agent to production. Everything works fine locally, but in prod, I’m seeing this error when trying to execute the agent:
TypeError: 'NoneType' object is not a mapping
(config = {**default_config, **(self.graph.config or {}), **config})
It’s coming from the _stream_events function inside copilotkit/langgraph_agent.py.
Local environment: fine
Production: crashes during execution after calling /copilotkit/agents/execute
Here’s what I suspect might be the issue:
-
self.graph.config is None in production.
-
Possibly due to the config not being initialized properly.
Or something’s missing in the deployment setup that’s present locally.
For backend, I’m using FastAPI to self-host the LangGraph agent with the add_fastapi_endpoint tool to serve the CopilotKit frontend. In front-end, I'm using CopilotKit Runtime.
For production, I'm using AWS ECS to deploy the backend API. I can confirm the copilotkit endpoint gets hit when interacting through the frontend.
Would appreciate any help, insights, or debugging tips. I’ve already done a bit of digging but haven’t found a solid fix yet.
Thanks in advance! 🙏