Thanks to visit codestin.com
Credit goes to github.com

Skip to content

πŸ› Bug: [CopilotKit] "Step 'chat_node' is already active for 'STEP_STARTED'" on concurrent users despite unique thread_id isolationΒ #2708

@sireeshdevaraj

Description

@sireeshdevaraj

♻️ Reproduction Steps

When multiple users (or browser tabs) interact with the CopilotKit chat simultaneously, the frontend throws:

Error: Step "chat_node" is already active for 'STEP_STARTED'
    at useChat.useAsyncCallback[runChatCompletion] (http://localhost:3000/_next/static/chunks/52940_%40copilotkit_react-core_dist_56801273._.js:1196:39)
    at useChat.useAsyncCallback[runChatCompletion].next (<anonymous>)
    at fulfilled (http://localhost:3000/_next/static/chunks/52940_%40copilotkit_react-core_dist_56801273._.js:48:32)

This occurs even when:

  • Each frontend instance sends a unique thread_id.
  • The FastAPI + LangGraph backend receives it and uses it.
  • Postgres checkpointer confirms separate, valid checkpoints per thread_id.

Reproduction Steps

  1. Open two browser windows (or incognito tabs).
  2. Each loads the same CopilotKit app:
    const threadId = crypto.randomUUID();
    <CopilotKit
      runtimeUrl="http://localhost:4000/copilotkit"
      threadId={threadId}
    />
  3. Send a message in both tabs at the same time.
  4. One succeeds (and stops streaming midway and throws a similar error), the other throws the STEP_STARTED error.

Versions

[runtime]
"@copilotkit/runtime": "^1.10.6"

[frontend]
"@ag-ui/langgraph": "0.0.18",
"@copilotkit/react-core": "1.10.6",
"@copilotkit/react-ui": "1.10.6",
"@copilotkit/runtime": "1.10.6",
"next": "15.3.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"zod": "^3.24.4"

[python]
langchain = "0.3.13"
langgraph = "^0.3.1"
langchain-postgres = "0.0.12"
langchain-community = "0.3.13"
langserve = "0.3.1"
langchain-openai = "0.2.14"
langchain-aws = "0.2.10"
langchainhub = "0.1.21"
ag-ui-langgraph = "^0.0.18"
copilotkit = "^0.1.70"


My Code:

Frontend

const threadId = useMemo(() => crypto.randomUUID(), []);

<CopilotKit
  runtimeUrl="http://localhost:4000/copilotkit"
  agent="copilot_agent"
  threadId={threadId}
/>

Node Runtime

app.use('/copilotkit', (req, res, next) => {
    const handler = copilotRuntimeNodeHttpEndpoint({
    endpoint: '/copilotkit',
    runtime: new CopilotRuntime({
                agents: {
                      'copilot_agent': new LangGraphHttpAgent({
                        url: process.env.LANGGRAPH_DEPLOYMENT_URL || "http://localhost:8000/copilot-agent/stream",
                      })
                    },
                }),
    serviceAdapter,
  });

  return handler(req, res, next);
});

Backend

add_langgraph_fastapi_endpoint(
    app=app,
    agent=LangGraphAGUIAgent(
        name="copilot_agent",
        description="Copilot chat agent for interactions",
        graph=copilot_graph,
    ),
    path="/copilot-agent/stream",
)

βœ… Expected Behavior

Needs to handle concurrent chat requests.

❌ Actual Behavior

Throwing an error:

Error: Step "chat_node" is already active for 'STEP_STARTED'

Call Stack

useChat.useAsyncCallback[runChatCompletion]
.next\static\chunks\52940_@copilotkit_react-core_dist_56801273._.js (1196:39)
useChat.useAsyncCallback[runChatCompletion].next
<anonymous> (0:0)
fulfilled
.next\static\chunks\52940_@copilotkit_react-core_dist_56801273._.js (48:32)

𝌚 CopilotKit Version

β”œβ”€β”€ @copilotkit/[email protected]
β”œβ”€β”€ @copilotkit/[email protected] -> .\node_modules\.pnpm\@[email protected]_0bcff3a74d6bfe852236e904d377f3cb\node_modules\@copilotkit\react-core
β”œβ”€β”€ @copilotkit/[email protected] -> .\node_modules\.pnpm\@[email protected]_c645aa3edf720b751045b826b7930dd6\node_modules\@copilotkit\react-ui
β”œβ”€β”€ @copilotkit/[email protected] -> .\node_modules\.pnpm\@[email protected]__4ef4253f41ef94dd8014e2bcd0ba1eb0\node_modules\@copilotkit\runtime

πŸ“„ Logs (Optional)

From Console: 

Uncaught (in promise) Error: Cannot send 'STEP_FINISHED' for step "chat_node" that was not started


Runtime error:

ERROR: Error in action execution argument stream
    component: "CopilotResolver.generateCopilotResponse"
    err: {
      "type": "CopilotKitError",
      "message": "Unknown error occurred",
      "stack":
          CopilotError: Unknown error occurred
              at new CopilotKitError (C:\work\node_modules\@copilotkit\shared\dist\index.js:349:5)
              at C:\work\node_modules\@copilotkit\runtime\dist\index.js:6553:15
              at C:\work\node_modules\rxjs\dist\cjs\internal\operators\catchError.js:13:51
              at OperatorSubscriber._this._error (C:\work\node_modules\rxjs\dist\cjs\internal\operators\OperatorSubscriber.js:43:21)
              at Subscriber.error (C:\work\node_modules\rxjs\dist\cjs\internal\Subscriber.js:60:18)
              at Subscriber._error (C:\work\node_modules\rxjs\dist\cjs\internal\Subscriber.js:84:30)
              at Subscriber.error (C:\work\node_modules\rxjs\dist\cjs\internal\Subscriber.js:60:18)
              at Observable.init [as _subscribe] (C:\work\node_modules\rxjs\dist\cjs\internal\observable\throwError.js:8:58)
              at Observable._trySubscribe (C:\work\node_modules\rxjs\dist\cjs\internal\Observable.js:41:25)
              at C:\work\node_modules\rxjs\dist\cjs\internal\Observable.js:35:31
      "extensions": {
        "name": "CopilotError",
        "statusCode": 500,
        "code": "UNKNOWN",
        "visibility": "toast",
        "severity": "critical",
        "troubleshootingUrl": null,
        "originalError": {
          "message": "Unknown error occurred",
          "stack":
              Error
                  at new CopilotKitError (C:\work\node_modules\@copilotkit\shared\dist\index.js:359:18)
                  at C:\work\node_modules\@copilotkit\runtime\dist\index.js:6553:15
                  at C:\work\node_modules\rxjs\dist\cjs\internal\operators\catchError.js:13:51
                  at OperatorSubscriber._this._error (C:\work\node_modules\rxjs\dist\cjs\internal\operators\OperatorSubscriber.js:43:21)
                  at Subscriber.error (C:\work\node_modules\rxjs\dist\cjs\internal\Subscriber.js:60:18)
                  at Subscriber._error (C:\work\node_modules\rxjs\dist\cjs\internal\Subscriber.js:84:30)
                  at Subscriber.error (C:\work\node_modules\rxjs\dist\cjs\internal\Subscriber.js:60:18)
                  at Observable.init [as _subscribe] (C:\work\node_modules\rxjs\dist\cjs\internal\observable\throwError.js:8:58)
                  at Observable._trySubscribe (C:\work\node_modules\rxjs\dist\cjs\internal\Observable.js:41:25)
                  at C:\work\node_modules\rxjs\dist\cjs\internal\Observable.js:35:31
        }
      },
      "code": "UNKNOWN",
      "statusCode": 500,
      "severity": "critical",
      "visibility": "toast"
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions