一键导入
kyoko-instrument
Wire an AI agent's telemetry into Kyoko and prove one real run shows up.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Wire an AI agent's telemetry into Kyoko and prove one real run shows up.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | kyoko-instrument |
| description | Wire an AI agent's telemetry into Kyoko and prove one real run shows up. |
| when_to_use | Use when the user says "set up telemetry", "instrument my agent", "send traces to Kyoko", "Kyoko is empty", "no traces yet", or "make my runs show up in Kyoko." Guides unknown repos by discovering the runtime, making the smallest safe change, and verifying one useful run landed in Kyoko. |
You are helping instrument an AI agent so its next meaningful run shows up in Kyoko. Kyoko is a local-first repair loop: the user's agent runs the workflow, a recorder captures the run/spans, and Kyoko ingests that telemetry so it can be inspected, diagnosed, and improved. Kyoko does not run the agent.
Your job is to get one real run into Kyoko with the smallest safe change, verify it actually landed, and only then enrich it. Use Kyoko's documented ingest paths. Do not invent endpoints or SDK calls.
A useful Kyoko run shows the input that triggered the agent, the final output or error, the model call, and the real tool executions.
There is one canonical shape and two ways to deliver it:
KyokoRecorder: open a run, open spans for model/tool calls,
finish them. This produces a kyoko.source_events.v1 payload.kyoko ingest. This writes straight to the SQLite database and needs no
running server. It cannot fail because a viewer is down.KyokoClient().ingest(...) POSTs to a running
kyoko serve. This is best-effort by default: if the server is not up it
warns and drops the telemetry rather than crashing the agent. Use it once
kyoko serve is confirmed running and you want runs to appear live.For non-Python stacks or existing OpenTelemetry setups, Kyoko also accepts OTLP
(POST /v1/traces) and ships source-adapter templates and importers. See
"Choosing The Path".
Do a quick read-only pass:
kyoko --version. If not, pipx install kyoko
(or python3 -m pip install kyoko)..kyoko/kyoko.db; otherwise pick one, e.g. /tmp/kyoko.db, and reuse it for
both ingest and kyoko serve.Timebox this. If discovery is not converging, report what you know and ask the
smallest concrete question, e.g. "I found app/agent.py and worker.py — which
should appear in Kyoko first?"
Goal: prove the pipe works with the smallest change, no server required.
For a Python agent, wrap one real entry point:
from kyoko import KyokoRecorder
recorder = KyokoRecorder(
profile_id="my-agent", # stable id for this workflow
profile_name="My Agent",
root_path=".",
agent_name="researcher", # which agent within the workflow
)
with recorder.run("handle request") as run: # the invocation boundary
with run.span("llm", kind="model") as span:
# ... the real model call ...
span.finish(status="succeeded", output_ref="output://answer")
run.finish(status="succeeded", summary="Answered the request.")
# Deliver offline — no server needed:
recorder.write_json("kyoko-run.json")
Then ingest the file:
kyoko ingest --db /tmp/kyoko.db kyoko-run.json --json
Run one representative invocation, then verify the run landed:
kyoko runs --db /tmp/kyoko.db --json
You should see the run with the right input/output. If you want to look at it in the dashboard, start the server against the same database:
kyoko serve --db /tmp/kyoko.db # then open http://127.0.0.1:8765
Phase 1 troubleshooting:
kyoko runs? Confirm the instrumented entry point actually executed and
that write_json ran before the process exited.kyoko.source_events.v1 object.KyokoClient().ingest(...) instead and seeing "telemetry not
delivered"? The server is not running. Either start kyoko serve on the same
DB, or switch to the offline write_json + kyoko ingest path above.--db path is used for ingest and for kyoko serve.
A run ingested into one database will not appear in a server started on another.Once a basic run lands, make it a useful debugging trace:
kind="model") and tool execution
(kind="tool"). Wrap the real tool body, not the decision to call it.usage, attributes, and output_ref/input_ref where you have them.span.fail(err) / run.fail(err) so the error is captured.POST /v1/live (the TypeScript client exposes ingestLive(...)), but this
is optional.Once runs flow reliably, switch delivery to live HTTP if the user wants runs to
appear in the dashboard as the agent runs: start kyoko serve and call
KyokoClient().ingest(recorder.to_source_events()) at the end of each run. It
is best-effort, so it will not break the agent when the server is down.
KyokoRecorder as above. Default.@kyoko/sdk package mirrors the Python API
(new KyokoRecorder(...), recorder.run(...), new KyokoClient().ingest(...)).
Note TS requires explicit run.start() / run.finish(...) (no context
manager).POST http://127.0.0.1:8765/v1/traces, or ingest exported OTLP JSON with
kyoko ingest-otlp --db <db> <file.json>. Do not stand up a second tracer
provider.kyoko source-adapter-template <path> --framework <fw> --profile-name <name>) or discover local sources
(kyoko discover-sources --db <db> --root-path .). Importers exist for some
formats (kyoko import-hermes-kanban, kyoko import-openclaw-sessions).If no path fits safely, stop and report the entry point and telemetry setup you found rather than guessing.
If the user only wants to see what Kyoko looks like with data, skip instrumentation and run the bundled demo:
kyoko demo --db /tmp/kyoko-demo.db --json
kyoko serve --db /tmp/kyoko-demo.db # open http://127.0.0.1:8765
Use the strongest available check:
kyoko runs --db <db> --json lists the run you just produced.kyoko current-run --db <db> --json and kyoko run-outline --db <db> <run-id> --json confirm the spans/structure.http://127.0.0.1:8765.Phase 1 success: one real invocation appears with input/output. Phase 2 success: the expected model/tool spans are visible. If a run exists but the content is not useful, verification failed — keep diagnosing or stop with exact evidence.
Verified:
Wired. I ran the agent once and confirmed a real run in Kyoko (
kyoko runsshows it). Open http://127.0.0.1:8765 to inspect it.
Needs user run:
Wired. Run
<command>now; the next run should land in<db>. Check withkyoko runs --db <db> --json, or open the dashboard withkyoko serve --db <db>.
Blocked:
I stopped before guessing.
<specific ambiguity/failure>. The next step is<specific user choice>.