What a Harness Contains
AChappieHarness value packages six fields. The SDK applies this context automatically at the start of every conversation so you don’t have to manage it manually.
A display name that identifies this harness. The model uses it to refer to the current surface.
A one-line description of what the app surface does. Keep it short and factual.
System-level instructions appended to every request. The SDK ships a default guardrail that prevents the model from claiming to be the Codex desktop app or accessing undeclared capabilities. Override this only if you have a good reason to replace the built-in guardrail entirely.
A list of plain-English strings that tell the model what the host app has wired up. The model will only claim to support capabilities that appear here.
Declared tools the model can call. Each entry names a function and describes what it does. Register tool handlers separately via
ChappieHostTool — the harness declaration is the model-facing manifest; the host tool is the Swift handler that runs it.Declared plugins available in this surface. Each plugin has a
name, description, and optional version.The Default Harness
ChappieHarness.default is a ready-made harness that works for general-purpose assistant surfaces. It carries the built-in guardrail instructions, four standard capabilities (multi-turn transcript, streaming responses, model selection, usage-limit awareness), and empty tool and plugin lists. Use it whenever you don’t need to customise the context.
Creating a Custom Harness
Declare a harness that matches your app’s actual surface, then pass it toChappie.client(harness:).
"Inline Harness" with no declared capabilities or tools.
ChappieHarness.none is a harness with all fields empty. It disables harness injection entirely, which means the model receives no surface context. Use it only in test scenarios where you want a completely clean transcript.Ready-Made Sample Harnesses
ChappieHarnessSamples ships four harnesses you can use directly or adapt as starting points:
.currentScreen
Declares
read_current_screen — returns app-provided text and state for the currently visible screen. Useful for context-aware in-app assistance..documents
Declares
read_selected_document_text — returns the user-selected document text and lightweight metadata. Built for document editing surfaces..photos
Declares
describe_selected_photo — returns app-provided metadata or a safe description for the selected photo. Scoped to app-owned assets only..inventory
Declares
lookup_item — looks up one inventory item by SKU. A good starting point for retail or warehouse apps.Declaring Tools in a Harness
When you want the model to be able to call a function your app implements, add aChappieHarnessTool entry to the harness and register the matching Swift handler when you create the client. The harness declaration tells the model what the tool does; the host tool provides the runtime implementation.