Skip to main content
Last updated on

Configuration

The CopilotKit integration can be configured through environment variables or explicit options passed to createOpenBoxCopilotKitAdapter(), createOpenBoxCopilotRuntime(), createOpenBoxApprovalRoute(), and createOpenBoxReadinessCheck().

Configuration Precedence

Configuration is resolved in this order:

  1. Explicit options passed in code
  2. Environment variables
  3. SDK defaults for optional fields

Runtime governance requires an OpenBox Core URL and an agent runtime key.

Environment Variables

Runtime Governance

VariableRequiredDefaultPurpose
OPENBOX_ENABLEDNoadapter defaultEnable or disable OpenBox. The adapter treats OPENBOX_ENABLED=true as enabled when no explicit config is provided.
OPENBOX_CORE_URLYes when enabled-OpenBox Core base URL for governance evaluation
OPENBOX_API_KEYYes when enabled-Agent runtime key, obx_live_* or obx_test_*
OPENBOX_AGENT_DIDYes, unless disabled-DID assigned to this OpenBox agent
OPENBOX_AGENT_PRIVATE_KEYYes, unless disabled-Base64 raw Ed25519 private key returned during identity provision or rotation

CopilotKit And LangGraph

VariableRequiredDefaultPurpose
AGENT_URLNohttp://localhost:8123LangGraph backend URL used by the CopilotKit runtime
LANGGRAPH_DEPLOYMENT_URLNo-alternative LangGraph deployment URL
LANGSMITH_API_KEYNoemptyLangSmith key when the LangGraph deployment requires it
OPENAI_BASE_URLUsually-OpenAI-compatible provider base URL for the reference agent
OPENAI_MODELUsually-chat model for the reference agent
OPENAI_API_KEYUsually-model provider API key

Platform And Optional Approval Route

VariableRequiredDefaultPurpose
OPENBOX_API_URLOnly for readiness checks or the optional demo-style approval route-OpenBox platform/backend API URL
OPENBOX_BACKEND_API_KEYOnly for readiness checks or the optional demo-style approval route-org/backend key, obx_key_*
OPENBOX_AGENT_IDOnly for readiness checks or the optional demo-style approval route-platform agent ID

Runtime governance uses OPENBOX_CORE_URL and OPENBOX_API_KEY. Approval creation, waiting, and enforcement do not require the backend key. OPENBOX_API_URL, OPENBOX_BACKEND_API_KEY, and OPENBOX_AGENT_ID are only needed for readiness checks or if you use the demo-style approval-decision route that posts a human approve/reject decision back to OpenBox.

Do not expose OPENBOX_BACKEND_API_KEY to the browser. Store it only in server-side environment variables.

Adapter Options

OptionDefaultUse it to
enabledOPENBOX_ENABLED or auto-enabled when a Core client is presentenable or disable OpenBox explicitly
coreUrlOPENBOX_CORE_URLset the OpenBox Core URL
apiKeyOPENBOX_API_KEYset the agent runtime key
agentIdentityOPENBOX_AGENT_DID + OPENBOX_AGENT_PRIVATE_KEYsign OpenBox requests with the registered agent identity
coreTimeoutMsCore client defaultset governance evaluation timeout
apiUrlOPENBOX_API_URLset platform/backend API URL for readiness and optional approval-route helpers
backendApiKeyOPENBOX_BACKEND_API_KEYset platform/backend key for readiness and optional approval-route helpers
backendTimeoutMsbackend client defaultset platform/backend timeout
agentIdOPENBOX_AGENT_IDidentify the platform agent for readiness and optional approval-route helpers
clientNameopenbox-copilotkitlabel SDK traffic
agentWorkflowTypeCopilotKitAgentset workflow type for runtime or LangGraph backend sessions
taskQueuecopilotkitset the OpenBox task queue label
selfGovernedToolNamesOpenBox default governed tool namesprevent recursive governance for tools that already call createGovernedCopilotTool()
governanceModeenforceevaluate in observe or enforce mode
failClosedtruechoose runtime behavior when OpenBox is unavailable
stricttruekeep strict validation and enforcement behavior
import {
createOpenBoxCopilotKitAdapter,
createOpenBoxCopilotRuntime,
} from "openbox-sdk/copilotkit";

const adapter = createOpenBoxCopilotKitAdapter({
agentWorkflowType: "CopilotKitRuntime",
taskQueue: "copilotkit-runtime",
selfGovernedToolNames: [
"openbox_governed_action",
"openbox_governed_approval_action",
"openbox_resume_governed_action",
],
clientName: "my-copilotkit-app",
coreTimeoutMs: 180_000,
});

const openboxRuntime = createOpenBoxCopilotRuntime({
runtime,
runner,
agents: ["default"],
adapter,
});

Agent DID Identity

Newly created OpenBox agents require cryptographic DID signing by default. When signing is enabled for the registered agent, set both values:

.env
OPENBOX_AGENT_DID=did:aip:550e8400-e29b-41d4-a716-446655440000
OPENBOX_AGENT_PRIVATE_KEY=base64_raw_ed25519_private_key

Rules:

  • set OPENBOX_AGENT_DID and OPENBOX_AGENT_PRIVATE_KEY together
  • store the private key in a secret manager or runtime secret store
  • never commit the private key
  • rotate the key from OpenBox if it is exposed
  • omit both values only when signing is disabled for the registered agent

Approval Decisions

Use createOpenBoxApprovalRoute() only when your app wants a server-side route that receives CopilotKit-rendered approve/reject clicks and posts those decisions back to OpenBox:

src/app/api/openbox/approvals/decide/route.ts
import { NextResponse } from "next/server";
import { createOpenBoxApprovalRoute } from "openbox-sdk/copilotkit";

const approvalRoute = createOpenBoxApprovalRoute({
clientName: "my-copilotkit-app",
backendTimeoutMs: 180_000,
});

export async function POST(request: Request) {
const body = await request.json();
const resolved = await approvalRoute.decide({
governanceEventId: body.governanceEventId,
decision: body.decision,
});

return NextResponse.json({
ok: true,
eventId: resolved.eventId,
});
}

This route matches the reference demo approval-decision path. It requires OPENBOX_API_URL, OPENBOX_BACKEND_API_KEY, and a governanceEventId, but that credential set is not required for normal runtime governance.

Failure Policy

For production, choose the failure policy intentionally:

SettingBehavior
governanceMode: "enforce"OpenBox verdicts affect execution
governanceMode: "observe"OpenBox observes decisions without enforcing them
failClosed: trueunavailable OpenBox governance prevents governed execution
failClosed: falseunavailable OpenBox governance allows execution to continue

Next Steps