#How to pass custom properties from react component to langgraph

1 messages · Page 1 of 1 (latest)

crimson slate
#

I'm attempting to pass custom values to the langgraph agent endpoint via the frontend:

    <CopilotKit
      runtimeUrl="/api/copilotkit"
      properties={{
        userId: 'vncq55ajcjhdng2wu0t5z8bq',
        propertyId: 'ctxz5vxl1asmzxnuas3ghxyz',
      }}
    >
      <Box
        component="main"
        sx={{
          flexFlow: 'center',
          alignItems: 'center',
          flexGrow: 1,
        }}
      >
        {children}
      </Box>
      <CopilotSidebar
        defaultOpen={false}
        instructions={
          'You are assisting the user as best as you can. Answer in the best way possible given the data you have.'
        }
        labels={{
          title: 'Sidebar Assistant',
          initial: 'How can I help you today?',
        }}
      />
    </CopilotKit>

I then capture the custom value via the following in langgraph (python):

def build_agents(context):
    return [
        LangGraphAgent(
            name="sample_agent",
            description="Answers questions about the weather and the subject property",
            graph=graph,
            langgraph_config={
                "propertyId": context["properties"].get("propertyId", "")
            },
        )
    ]

This seems to cause the client to sometimes omit the properties value altogether in a non-deterministic way. Is there something I'm missing?

distant anchor
#

@crimson slate how often does this happen? Have you observed any pattern?

crimson slate
#

Happens consistently. In order to recover, I have been restarting my dev server + refreshing the UI on the browser

distant anchor
#

Thanks for the info, I am passing this to the team, they'll look into this and get back to you.

crimson slate
#

Some logs from the server side when properties not defined:

2025-06-17 09:46:36,797 - copilotkit.sdk - INFO - Handling info request:
2025-06-17 09:46:36,798 - copilotkit.sdk - INFO - --------------------------
2025-06-17 09:46:36,798 - copilotkit.sdk - INFO - Context:
2025-06-17 09:46:36,799 - copilotkit.sdk - INFO - {'frontend_url': None,
 'headers': Headers({'host': 'localhost:8000', 'connection': 'keep-alive', 'content-type': 'application/json', 'x-api-key': '', 'accept': '*/*', 'accept-language': '*', 'sec-fetch-mode': 'cors', 'user-agent': 'node', 'accept-encoding': 'gzip, deflate', 'sentry-trace': '4ce2826d8dc2c688efa17a5d6e182418-7f845cba1df073c2-1', 'baggage': 'sentry-environment=development,sentry-public_key=eaeedaa62d0fc9289a941f1a2e81984e,sentry-trace_id=4ce2826d8dc2c688efa17a5d6e182418,sentry-sample_rate=1,sentry-transaction=GET%20%2Fdashboard%2Fproperties%2F%5Bproperty%5D,sentry-sampled=true', 'content-length': '17'}),
 'properties': {}}
2025-06-17 09:46:36,799 - copilotkit.sdk - INFO - Actions:
2025-06-17 09:46:36,799 - copilotkit.sdk - INFO - []
2025-06-17 09:46:36,799 - copilotkit.sdk - INFO - Agents:
2025-06-17 09:46:36,799 - copilotkit.sdk - INFO - []
2025-06-17 09:46:36,799 - copilotkit.sdk - INFO - --------------------------
2025-06-17 09:46:36,802 - uvicorn.access - INFO - 127.0.0.1:65205 - "POST /copilotkit/info HTTP/1.1" 200
#

vs when the server side shows when properties are defined:

2025-06-17 09:46:36,802 - uvicorn.access - INFO - 127.0.0.1:65205 - "POST /copilotkit/info HTTP/1.1" 200
2025-06-17 09:47:20,037 - copilotkit.langgraph_agent - WARNING - Warning: merge_state is deprecated, use copilotkit_config instead
2025-06-17 09:47:20,038 - copilotkit.sdk - INFO - Handling info request:
2025-06-17 09:47:20,038 - copilotkit.sdk - INFO - --------------------------
2025-06-17 09:47:20,038 - copilotkit.sdk - INFO - Context:
2025-06-17 09:47:20,039 - copilotkit.sdk - INFO - {'frontend_url': 'http://localhost:8080/dashboard/properties/ctxz5vxl1asmzxnuas3ghxyz',
 'headers': Headers({'host': 'localhost:8000', 'connection': 'keep-alive', 'content-type': 'application/json', 'x-api-key': '', 'accept': '*/*', 'accept-language': '*', 'sec-fetch-mode': 'cors', 'user-agent': 'node', 'accept-encoding': 'gzip, deflate', 'sentry-trace': '4ce2826d8dc2c688efa17a5d6e182418-65642863bfd8070c-1', 'baggage': 'sentry-environment=development,sentry-public_key=eaeedaa62d0fc9289a941f1a2e81984e,sentry-trace_id=4ce2826d8dc2c688efa17a5d6e182418,sentry-sample_rate=1,sentry-transaction=GET%20%2Fdashboard%2Fproperties%2F%5Bproperty%5D,sentry-sampled=true', 'content-length': '176'}),
 'properties': {'propertyId': 'ctxz5vxl1asmzxnuas3ghxyz',
                'userId': 'kffm9s0yv9q5o1vu3mxgr192'}}
cerulean trellis
crimson slate
#

Thanks! I'll try switching properties to configurable