#Why don't Copilot actions trigger with my self-hosted server using LangChain adapter and GEMINI_API_

1 messages · Page 1 of 1 (latest)

half sparrow
#

[Help Needed] Copilot Action Triggering with LangChain Adapter and Gemini API

I’m integrating CopilotKit in a React app and facing an issue with triggering actions using my own server.

Setup:

Using LangChain adapter with Gemini API (gemini-1.5-flash model).
Express server handles API calls and user messages.
Server Code:

import express from "express";
import { CopilotRuntime, LangChainAdapter, copilotRuntimeNodeHttpEndpoint } from "@copilotkit/runtime";
import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
import dotenv from "dotenv";

dotenv.config();

const app = express();
const model = new ChatGoogleGenerativeAI({
  model: "gemini-1.5-flash",
  apiKey: process.env.GEMINI_API_KEY,
  region: "us-central1",
});

const serviceAdapter = new LangChainAdapter({
  chainFn: async ({ messages, tools }) => {
    return model.bindTools(tools).stream(messages);
  },
});

app.use("/copilotkit", (req, res, next) => {
  const runtime = new CopilotRuntime();
  const handler = copilotRuntimeNodeHttpEndpoint({
    endpoint: "/copilotkit",
    runtime,
    serviceAdapter,
  });
  return handler(req, res, next);
});

app.listen(4000, () => {
  console.log("Listening at http://localhost:4000/copilotkit");
});

Issue:

When using the publicApiKey="<your-copilot-cloud-public-api-key>", everything works: messages, responses, and actions.
With my own server, only messages and responses work, but actions (like adding tasks) don’t trigger.
Question:

What could be missing in the configuration to trigger actions when using my own server?
Any advice would be greatly appreciated!

scenic jetty
#

Hi @half sparrow, thanks for flagging this.
I've notified the team and we are looking into this.
We'll reproduce and let you know what we find.

half sparrow
#

👍

scenic jetty
#

Hi @half sparrow, I wanted to circle back around with an update. The engineering team has created a ticket to look into this issue.
Once I hear something back, I'll let you know.

half sparrow
#

Hi @scenic jetty
Thank you for the update and for following up on this. I appreciate you and the engineering team looking into this issue. I'll look forward to hearing back from you once there’s an update. Please don’t hesitate to reach out if you need any additional information from my side.