Check a handler locally
From a Checkfu checkout, run the example’s protocol tests with Bun. The tests send authenticated version 1 requests directly to the Worker’sfetch handler. They use a scripted provider response, so no model credentials or deployed stage are needed.
CustomHarnessResponse so malformed fields are caught before deployment. Use the example test as a fixture for your own handler. Run a real Session after deploying to verify the endpoint, credentials, and model connection.
Deploy the example
The example Worker calls the OpenAI Chat Completions API and supports workspace tool calls. In a checkout of the Checkfu repo, run:CHECKFU_CUSTOM_HARNESS_TOKEN, such as a value from openssl rand -hex 32. Load that token into HARNESS_TOKEN in your shell and export the registration before running checkfu deploy.
.env under deploy/stages/<stage>/ in your Checkfu config directory. The registration pair is enough when the harness supplies its own model credentials. A non-production local Alchemy dev stack also accepts a loopback HTTP URL. Each Agent version pins its harness choice and model ID, and the deployment supplies the implementation behind custom.
Create an Agent and run a Session
Create an Agent with thecustom harness and a model ID understood by the endpoint.
harness: custom in Agent YAML, select Custom in the Dashboard, or pass harness: "custom" when creating or updating an Agent through the API, SDK, or management MCP. Sessions keep using the Agent version they started with. Model-only turns can run without a Linux workspace. Shell commands and repository checkouts can start one. To share a file, write it under /mnt/session/outputs.
Implement your endpoint
Checkfu sends authenticated JSON viaPOST. Use the CustomHarnessRequest and CustomHarnessResponse codecs from @checkfu/sdk/CustomHarness for the complete version 1 contract. Each request includes session_id, operation_id, and a one-based step. It also includes the model and instructions, user input, recent published conversation text, available tools, and any tool results from the current turn.
Return one of these JSON objects on each step.
Content-Type: application/x-ndjson. Write one UTF-8 JSON frame per line, finish with one reply, tool_call, or error frame, and close the response. Decode frames with CustomHarnessStreamFrame from @checkfu/sdk/CustomHarness. A thinking_start frame opens a thinking indicator. A text_delta frame appends to the preview. The full stream has the same 128 KiB limit as a JSON response.
checkfu/<provider>/<model>, such as checkfu/openai/gpt-4o-mini. Set the matching OpenAI or Anthropic API key on the Checkfu deployment. Your endpoint can call checkfu_generate_text with arguments: { "prompt": "Draft a title for the rail timetable." }. The name checkfu_generate_text is reserved for this tool when using a Checkfu-managed model. The next step receives the text in tool_results. Checkfu uses the selected model and records each provider request in the Session’s Usage panel. Include the instructions and conversation context you want to send in the prompt. Calls your endpoint makes directly to a provider are outside that ledger.
Version 1 returns one reply, one tool_call, or error per step. The example Worker maps limited, filtered, or unrecognized provider completions to error.
Each tool result has an is_error flag and can carry truncated: true when the output is partial. Pass both flags to the model with the result text and call ID. The example Worker encodes the text and flags together as JSON in the tool message.
Each HTTP step has 60 seconds to send and close its response. A Session interruption cancels the outstanding HTTP request and blocks later workspace calls. An external service controls how it reacts to disconnection. Checkfu stores completed results and interrupts a started attempt whose outcome it cannot recover, without reissuing that attempt. Keep externally managed side effects idempotent. Use the tuple (session_id, operation_id, step) for correlation and deduplication. Operation IDs are scoped to each Session.