Kitaru adapter builder
First select the smallest honest supported integration. Build an adapter inside
the user's project only when no supported route meets the requested recording
and replay boundary. Preserve the framework's public entrypoint and report
exactly what the selected or custom adapter can observe, record, replay, and
recover from.
Do not assume every framework can support the same fidelity. A useful result is
either a locally tested adapter or a precise blocker tied to the installed
versions and public hooks.
Core contract
- Start with read-only inspection of the user's project and installed packages.
- Prefer supported Kitaru adapters, importers, or OTLP export when they meet the
requested recording and replay needs. Do not create a duplicate integration.
- For an already instrumented Python agent using Langfuse, Braintrust,
LangSmith, Logfire, or Arize Phoenix, check the provider's importer-backed
adapter before proposing custom code. Read the Python adapter
reference for the package and capability
contract.
- Treat the user's installed SDK and framework as authority. Use Kitaru reference
adapters as patterns, not as source to copy or as proof of a published API.
- Use only public framework hooks. Offer a coarser boundary or stop when complete
coverage would require private internals.
- Implement in the user's project first. Do not edit Kitaru core or prepare an
upstream contribution unless the user separately approves that work.
- Keep per-run session IDs, clients, node indexes, buffers, replay state, and
framework context isolated. Never store invocation state on a shared wrapper.
- Treat a partially recorded run as partial or failed evidence. Never call it a
complete trace because the application returned successfully.
- Treat replay as execution, not a transaction. Block unknown or write-capable
side effects unless the selected policy and user approval make them safe.
- Never install dependencies, call credentialed providers, create a remote Kitaru
session, execute write-capable tools, or publish changes without the relevant
approval.
- Run every Kitaru CLI command and SDK script with
KITARU_ACTIVE_SKILL=kitaru-adapter-builder set so the server attributes the
resulting activity to this skill.
- Start or restart a user-controlled worker with
--concurrency 10. Use
KITARU_WORKER_CONCURRENCY=10 only when the launch surface exposes worker
settings through environment variables instead of CLI options.
Route from the project
Begin in the project that contains the real agent entrypoint.
- Read the repository instructions and inspect the working tree. Preserve all
existing and concurrent changes.
- Identify the package manager, lockfile, runtime, language, framework and
version, Kitaru package and version, public agent entrypoint, and invocation
modes the application actually uses.
- Route by the entrypoint's runtime:
- For Python, read the Python adapter reference.
- For TypeScript, read
the TypeScript adapter reference.
- For another runtime, stop with an unsupported-language report.
- Read the adapter method, search the project,
installed packages, and current Kitaru documentation for a compatible
adapter, importer, or OTLP path, and create the adapter assessment before
editing code.
- Read validation and reporting before
finalizing the design or writing tests.
In a mixed repository, route from the process that executes the agent. Do not
load both language references merely because both languages exist somewhere in
the repository.
If a supported importer-backed adapter fits the provider, public Python
entrypoint, and requested recording boundary, install it only after approval and
wrap that entrypoint. It creates a Kitaru session from the provider trace after
the run; it does not intercept model or tool calls. Do not build a duplicate
adapter merely to obtain recording. Use a native adapter instead when the
request needs runtime overrides or a non-passthrough tool policy.
If the framework already exports traces in a format no built-in importer
supports and that post-hoc evidence meets the user's goal, continue with
kitaru-importer-builder instead of wrapping the live entrypoint. Carry forward
the repository and revision, public entrypoint, framework and version, export
source and shape, Kitaru package and version, target agent and version, and
requested evidence. Choose this route once; do not bounce back merely because
the importer mentions an adapter as an alternative.
Establish the requested fidelity
Separate these questions before choosing an implementation:
| Question |
Possible answer |
| Recording boundary |
Whole invocation, turn, model step, tool call, subagent call, or coarser span |
| Replay tier |
Input rerun, turn replay, framework-native boundary replay, finer checkpoint replay, or not claimed |
| Tool visibility |
Local tools, MCP tools, provider-native tools, hidden framework tools, or unknown |
| Invocation modes |
Async, sync, streaming, manual iteration, batch, handoff, resume, interrupt, or durable execution |
| Failure policy |
Kitaru failure fails the invocation, or recording is best effort with an explicit degraded result |
Do not use “replay” without naming the tier. Running the same root input again is
an input rerun, not deterministic replay.
For streaming, keep three claims separate:
- the application still yields tokens or events;
- the adapter observes the stream through completion, failure, cancellation,
and abandonment;
- replay reproduces the original chunks or timing.
Supporting one does not prove the others.
Stop before writing code when necessary
Stop and give the exact reason when any of these apply:
- a compatible existing adapter, importer, or OTLP route satisfies the request;
- the project is not Python or TypeScript;
- no usable public Kitaru SDK contract is installed or approved for installation;
- the framework exposes no public hook at the required boundary;
- the only Python entrypoint is synchronous and the available Kitaru contract is
async, with no documented safe async framework hook;
- the requested behavior depends on hidden provider or framework activity;
- replay safety requires match cardinality, occurrence identity, or another
Kitaru contract the installed SDK does not expose;
- an incomplete imported baseline cannot prove the calls needed for effectful
replay;
- the required dependency is unpublished and the user has not approved a local
tarball or workspace-link path.
Do not replace a missing SDK contract with handwritten REST calls, an improvised
event-loop bridge, private framework imports, or copied draft plugin code.
Use explicit approval gates
Read-only discovery does not need a separate approval. Ask before each action
that changes the user's environment or external state:
| Action |
Required approval |
| Install or change a dependency |
Exact package, version, and package-manager command |
| Use a local unpublished TypeScript artifact |
Exact tarball or workspace-link path |
| Call a model or other credentialed provider |
Provider, expected calls, and cost or data consequence |
| Create a remote Kitaru session |
Endpoint, tenant, captured categories, and test purpose |
| Permit live tool passthrough |
Exact tools, effect class, and miss condition |
| Prepare an OSS contribution |
Target repository, files, and contribution scope |
Approval for one row does not authorize another.
Implement in bounded checkpoints
Use this order:
- Confirm the public framework hook with a deterministic local probe.
- Freeze the adapter assessment and capability claims.
- Implement per-run state and the session/root lifecycle.
- Add model, tool, subagent, and stream observation only where public hooks
prove it.
- Add replay only after the baseline-admissibility and side-effect gates pass.
- Define bounded, allowlisted payload projections before broad serialization.
- Test success, primary application failure, Kitaru write failure, concurrency,
cancellation, and every claimed replay policy with fakes.
- Inspect the recorded session and node tree rather than trusting only the
application result.
- Produce the capability report.
Keep the framework's public signature, return value, configured callbacks,
exception behavior, and type surface intact. If preserving them is not possible,
report the API change before implementing it.
Handle failures as evidence
Preserve the first application or adapter failure. Attempt terminal failure
recording without masking that failure, and report later recording or cleanup
errors separately.
If session creation succeeds and a later write fails:
- retain already confirmed nodes;
- record the last confirmed write;
- try to mark the root and session failed;
- do not claim the trace is complete;
- apply the adapter's documented Kitaru-availability policy to the application
invocation.
An incomplete imported trace is a replay-input problem here. Assess it and stop
unsafe replay. Do not repair or redesign the importer inside this skill.
Resume safely
On a resumed run, re-read the project, working tree, installed versions, adapter
assessment, and tests. Recheck that the chosen hooks and SDK symbols still exist.
Do not overwrite user changes or repeat dependency installation and remote smoke
tests merely because an earlier transcript is unavailable.
Finish with an honest handoff
Use the capability-report format in
validation and reporting. State what
was verified with fakes, what was verified against a real Kitaru session, and
what remains unsupported or unverified.
After every claimed mode passes locally, offer a separate optional contribution
step. Do not imply that a project-local adapter is upstream-ready merely because
the happy path works.
1---2name: kitaru-adapter-builder3description: Select a supported Kitaru adapter or build a project-local one for an unsupported Python or TypeScript agent framework. Use when a user wants to record or replay framework-native agent runs in Kitaru, needs a custom adapter, has no supported Kitaru integration for their framework, or needs to assess whether public framework hooks and the installed Kitaru SDK can support an adapter.4---56# Kitaru adapter builder78First select the smallest honest supported integration. Build an adapter inside9the user's project only when no supported route meets the requested recording10and replay boundary. Preserve the framework's public entrypoint and report11exactly what the selected or custom adapter can observe, record, replay, and12recover from.1314Do not assume every framework can support the same fidelity. A useful result is15either a locally tested adapter or a precise blocker tied to the installed16versions and public hooks.1718## Core contract1920- Start with read-only inspection of the user's project and installed packages.21- Prefer supported Kitaru adapters, importers, or OTLP export when they meet the22 requested recording and replay needs. Do not create a duplicate integration.23- For an already instrumented Python agent using Langfuse, Braintrust,24 LangSmith, Logfire, or Arize Phoenix, check the provider's importer-backed25 adapter before proposing custom code. Read [the Python adapter26 reference](references/python-adapters.md) for the package and capability27 contract.28- Treat the user's installed SDK and framework as authority. Use Kitaru reference29 adapters as patterns, not as source to copy or as proof of a published API.30- Use only public framework hooks. Offer a coarser boundary or stop when complete31 coverage would require private internals.32- Implement in the user's project first. Do not edit Kitaru core or prepare an33 upstream contribution unless the user separately approves that work.34- Keep per-run session IDs, clients, node indexes, buffers, replay state, and35 framework context isolated. Never store invocation state on a shared wrapper.36- Treat a partially recorded run as partial or failed evidence. Never call it a37 complete trace because the application returned successfully.38- Treat replay as execution, not a transaction. Block unknown or write-capable39 side effects unless the selected policy and user approval make them safe.40- Never install dependencies, call credentialed providers, create a remote Kitaru41 session, execute write-capable tools, or publish changes without the relevant42 approval.43- Run every Kitaru CLI command and SDK script with44 `KITARU_ACTIVE_SKILL=kitaru-adapter-builder` set so the server attributes the45 resulting activity to this skill.46- Start or restart a user-controlled worker with `--concurrency 10`. Use47 `KITARU_WORKER_CONCURRENCY=10` only when the launch surface exposes worker48 settings through environment variables instead of CLI options.4950## Route from the project5152Begin in the project that contains the real agent entrypoint.53541. Read the repository instructions and inspect the working tree. Preserve all55 existing and concurrent changes.562. Identify the package manager, lockfile, runtime, language, framework and57 version, Kitaru package and version, public agent entrypoint, and invocation58 modes the application actually uses.593. Route by the entrypoint's runtime:60 - For Python, read [the Python adapter reference](references/python-adapters.md).61 - For TypeScript, read62 [the TypeScript adapter reference](references/typescript-adapters.md).63 - For another runtime, stop with an unsupported-language report.644. Read [the adapter method](references/adapter-method.md), search the project,65 installed packages, and current Kitaru documentation for a compatible66 adapter, importer, or OTLP path, and create the adapter assessment before67 editing code.685. Read [validation and reporting](references/validation-and-reporting.md) before69 finalizing the design or writing tests.7071In a mixed repository, route from the process that executes the agent. Do not72load both language references merely because both languages exist somewhere in73the repository.7475If a supported importer-backed adapter fits the provider, public Python76entrypoint, and requested recording boundary, install it only after approval and77wrap that entrypoint. It creates a Kitaru session from the provider trace after78the run; it does not intercept model or tool calls. Do not build a duplicate79adapter merely to obtain recording. Use a native adapter instead when the80request needs runtime overrides or a non-passthrough tool policy.8182If the framework already exports traces in a format no built-in importer83supports and that post-hoc evidence meets the user's goal, continue with84`kitaru-importer-builder` instead of wrapping the live entrypoint. Carry forward85the repository and revision, public entrypoint, framework and version, export86source and shape, Kitaru package and version, target agent and version, and87requested evidence. Choose this route once; do not bounce back merely because88the importer mentions an adapter as an alternative.8990## Establish the requested fidelity9192Separate these questions before choosing an implementation:9394| Question | Possible answer |95|---|---|96| Recording boundary | Whole invocation, turn, model step, tool call, subagent call, or coarser span |97| Replay tier | Input rerun, turn replay, framework-native boundary replay, finer checkpoint replay, or not claimed |98| Tool visibility | Local tools, MCP tools, provider-native tools, hidden framework tools, or unknown |99| Invocation modes | Async, sync, streaming, manual iteration, batch, handoff, resume, interrupt, or durable execution |100| Failure policy | Kitaru failure fails the invocation, or recording is best effort with an explicit degraded result |101102Do not use “replay” without naming the tier. Running the same root input again is103an input rerun, not deterministic replay.104105For streaming, keep three claims separate:1061071. the application still yields tokens or events;1082. the adapter observes the stream through completion, failure, cancellation,109 and abandonment;1103. replay reproduces the original chunks or timing.111112Supporting one does not prove the others.113114## Stop before writing code when necessary115116Stop and give the exact reason when any of these apply:117118- a compatible existing adapter, importer, or OTLP route satisfies the request;119- the project is not Python or TypeScript;120- no usable public Kitaru SDK contract is installed or approved for installation;121- the framework exposes no public hook at the required boundary;122- the only Python entrypoint is synchronous and the available Kitaru contract is123 async, with no documented safe async framework hook;124- the requested behavior depends on hidden provider or framework activity;125- replay safety requires match cardinality, occurrence identity, or another126 Kitaru contract the installed SDK does not expose;127- an incomplete imported baseline cannot prove the calls needed for effectful128 replay;129- the required dependency is unpublished and the user has not approved a local130 tarball or workspace-link path.131132Do not replace a missing SDK contract with handwritten REST calls, an improvised133event-loop bridge, private framework imports, or copied draft plugin code.134135## Use explicit approval gates136137Read-only discovery does not need a separate approval. Ask before each action138that changes the user's environment or external state:139140| Action | Required approval |141|---|---|142| Install or change a dependency | Exact package, version, and package-manager command |143| Use a local unpublished TypeScript artifact | Exact tarball or workspace-link path |144| Call a model or other credentialed provider | Provider, expected calls, and cost or data consequence |145| Create a remote Kitaru session | Endpoint, tenant, captured categories, and test purpose |146| Permit live tool passthrough | Exact tools, effect class, and miss condition |147| Prepare an OSS contribution | Target repository, files, and contribution scope |148149Approval for one row does not authorize another.150151## Implement in bounded checkpoints152153Use this order:1541551. Confirm the public framework hook with a deterministic local probe.1562. Freeze the adapter assessment and capability claims.1573. Implement per-run state and the session/root lifecycle.1584. Add model, tool, subagent, and stream observation only where public hooks159 prove it.1605. Add replay only after the baseline-admissibility and side-effect gates pass.1616. Define bounded, allowlisted payload projections before broad serialization.1627. Test success, primary application failure, Kitaru write failure, concurrency,163 cancellation, and every claimed replay policy with fakes.1648. Inspect the recorded session and node tree rather than trusting only the165 application result.1669. Produce the capability report.167168Keep the framework's public signature, return value, configured callbacks,169exception behavior, and type surface intact. If preserving them is not possible,170report the API change before implementing it.171172## Handle failures as evidence173174Preserve the first application or adapter failure. Attempt terminal failure175recording without masking that failure, and report later recording or cleanup176errors separately.177178If session creation succeeds and a later write fails:179180- retain already confirmed nodes;181- record the last confirmed write;182- try to mark the root and session failed;183- do not claim the trace is complete;184- apply the adapter's documented Kitaru-availability policy to the application185 invocation.186187An incomplete imported trace is a replay-input problem here. Assess it and stop188unsafe replay. Do not repair or redesign the importer inside this skill.189190## Resume safely191192On a resumed run, re-read the project, working tree, installed versions, adapter193assessment, and tests. Recheck that the chosen hooks and SDK symbols still exist.194Do not overwrite user changes or repeat dependency installation and remote smoke195tests merely because an earlier transcript is unavailable.196197## Finish with an honest handoff198199Use the capability-report format in200[validation and reporting](references/validation-and-reporting.md). State what201was verified with fakes, what was verified against a real Kitaru session, and202what remains unsupported or unverified.203204After every claimed mode passes locally, offer a separate optional contribution205step. Do not imply that a project-local adapter is upstream-ready merely because206the happy path works.