Skip to main content
Use the optional harnest-threadify package to link sessions to Threadify and coordinate shared business workflows.
The optional integration is maintained in packages/harnest-threadify in the Harnest repository. Contract permission waits require threadify-sdk>=0.4.0,<0.5.

Configure the agent

For development from the Harnest checkout, install into the environment running that checkout:
Copy the following into your existing agent’s lifecycle/telemetry.py. Keep its session storage configuration. Change service_name to a stable application/environment identity and select your business tools and attribute names.
lifecycle/telemetry.py
Provide THREADIFY_API_KEY through the server environment or deployment secret store, then start the agent. Compilation never reads the key or opens a connection.

Business data only

ADK and LangGraph use the same filter. Exact attribute names are required; attribute wildcards are rejected. Strings are limited to 256 characters by default. Framework payload namespaces such as gen_ai.*, llm.*, and exception.* stay excluded even if named in the attribute allowlist. Other telemetry destinations receive their original spans. Use static business-step names and deliberately select non-sensitive attribute values:

Session ownership

Session links use a hash of application, user, and session identity. sessionId is a Threadify reference; equal IDs from different users remain separate. HTTP scopes cover streaming and cancellation; agent hooks cover other supported invocations. Native sessions are linked on first invocation. Later turns reuse the same Threadify thread. Route a session to one worker during thread creation. Creation is serialized within one integration instance, and ambiguous results require lookup before retry. Shared contract workflows instead use Threadify’s atomic application-owned key. Each instance tracks up to 10,000 linked or unresolved sessions. At capacity, new links are skipped. Missing credentials fail startup; remote failures let the agent continue. A failed startup connection requires restart. Export is best effort, not a durable audit ledger.

Native SDK access

Use native async operations on the application’s event loop. Native SDK operations are explicit application actions and bypass the telemetry filter. Completing a native thread ends that business workflow; the integration does not automatically start a replacement for the same session.

Check a shared workflow before a tool call

The workflow owner opens a versioned contract with workflow(key, contract=..., role=...) and returns the thread ID after authorizing the user. The agent joins with join_workflow(thread_id, role=...). Both require a working Threadify connection. For an action with a side effect, use wait_for before calling the backend. Threadify’s can query previews eligibility; it does not claim an invocation. Pass a persisted invocation ID to WaitOptions and use that ID as the backend’s idempotency key.
Report the backend’s actual outcome after the claimed action. Reconcile ambiguous responses by idempotency key before retrying. Recover a timed-out report validation with wait_for_validation and its step ID. Try examples/threadify-refund for an order-service prerequisite, human approval, a claimed refund invocation, and an idempotent backend. It uses synthetic in-memory orders; replace the demo backend with authorized services for real refunds. To try the project from the Harnest checkout, create its contract in Threadify and supply API keys allowed to report as orders and processor. The development Harnest principal is _harnest_neutral; use that value when preparing the synthetic order unless you configure authentication.
Set OPENAI_MODEL, OPENAI_BASE_URL, and any required model key before serving. The example reads these values from the environment. Complete the Harnest approval request when the agent calls issue_refund.

OTLP/HTTP Protobuf

The default transport uses Threadify’s native SDK. If your deployment supplies a standard OTLP/HTTP traces endpoint, select it when constructing the class:
Import os and configure your receiver’s exact URL and headers. Filtering runs before serialization; the receiver must honor threadify.thread_id and session references. The SDK still manages session links and native access.

API reference

Reference: harnest_threadify.