Skip to main content
A deployment operator can register one custom harness and select it on any Agent in that Checkfu deployment. The harness can run in a Cloudflare Worker, a Durable Object, or a service in a container. Checkfu maintains the Session turn record and grants workspace access through its standard tools. Your harness can call models with its own credentials or use a Checkfu-managed text model.

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’s fetch handler. They use a scripted provider response, so no model credentials or deployed stage are needed.
Start with a text reply. In a separate test, return a tool call and supply its result in the next step. Decode every reply with 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:
Use a private random token for 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.
Replace the example URL with the exact HTTPS endpoint receiving each step. The CLI saves the registration in the private per-stage .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 the custom harness and a model ID understood by the endpoint.
You can set 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 via POST. 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.
A handler can send live previews with 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 displays preview frames while the step runs and records the terminal result in the Session. Checkfu validates calls against the tools it advertised and includes the result on the next step. Use an ID unique within the turn. When an MCP or OpenAPI tool requires approval, Checkfu waits for the Session’s approval or denial. When you call an Agent-declared custom tool, Checkfu waits for the application to submit its result. The next step receives that result or a denial through the same tool-result input. The endpoint can report token usage with the final text reply. For a Checkfu-managed text model, set the Agent model to 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.