add-traces
БесплатноБез исполняемых скриптовНе проверенMake every run of a @statelyai/agent or XState machine leave a replayable, stamped trace — an event log thread plus trace events — so evals and…
от statelyai★ 86 звёзд на GitHubОб этом скилле
Add traces to an agent machine
Targets
@statelyai/agent2.0 alpha, as on thenextbranch. APIs change between alphas: when a call here does not match the installed package, checknode_modules/@statelyai/agent/CHANGELOG.md.
Every run should leave two records, both stamped with what produced it:
| Record | What it is | Read by |
|---|---|---|
| Event log thread | The external inputs the machine consumed, in order. The source of truth | replay, getDecisionAttempts, getUsageFromEvents |
| Trace events | Observations: transitions with from, decision requests with offered options |
foldTraces, OpenTelemetry, debugging |
version the machines → pick a store → name threads → stamp → collect trace events → prove replay → hand back
This is step 2 of 4. Before: loop-to-machine. Next: add-evals, then improve-machine.
Hard rules
- Traces never change behavior. Recording is an observer. No branch reads a trace. An
onTraceoronTransitionhandler that throws is reported withconsole.errorand skipped. The store is different: it is write-ahead, so a failed write stops the run withcause: "journal". Ask the user whether a run should fail when its log cannot be written (the store) or carry on unrecorded (record fromonEventinstead). - A trace must name what produced it. A run with no machine version or policy version cannot be used to compare versions, so it is useless to the improver.
- Replay is the test. A log that does not replay to the run's final state with zero model calls is not a trace yet.
- No secrets or personal data in metadata or thread ids. Use ids, not names or emails. The log itself holds the machine's input and every event verbatim (a ticket's text, a customer's reply), and trace snapshots hold the context: in production, redact or encrypt them per your data rules, and ask the user which applies.
1. Version the machines
Declare version on every machine whose runs you record: the environment and, if there is one, the policy machine.
export const deskMachine = deskSetup.createMachine({ id: "refund-desk", version: "1", ... });
Also name the decider version: whatever produces the model's answers. It is the policy machine's version when there is one. Otherwise it is a label for the model, its settings, and its prompts (gpt-6-luna.xhigh.p<hash of the prompts>); this holds for a machine with only text requests too. When the prompts are private to another module (a route file), export a prompt version from that module rather than guessing; a release or commit id is the fallback. In tests it is the stand-in model's name (careful). Runs by different deciders must never share a label.
No decider. A machine with no model decisions (a scheduler, a tool runner whose model only picks tools inside one text request) still stamps a decider version: whatever decides what runs. That is the version of the policy engine or approval rules the guards read (rules.v4, a hash of the persisted rules file), plus the request config version when a text request picks tools. Stamp both in metadata (rulesVersion, requestVersion). Thread ids keep the formats below; a non-empty thread resumes with its original stamp, so a run under a changed rule set or request config never resumes an old thread: start a new one (prod:<domain id>:<rulesVersion>:<requestVersion>). A version bridge (docs/persistence.md) applies only when the machine version changes, with the old events and a snapshot; a changed rule set or request config alone never bridges. A changed rule set must never share a label with the old one. getDecisionAttempts is always empty here; record approval verdicts as events so they reach the log.
- Every log entry carries
machineVersion. Without a declaredversionit falls back to a structural hash that skips functions, and in XState v6 the guards and targets live in transition functions. Changing a guard would not change the hash. - Bump
versionon every behavior change. Adding recording is not one: it only observes.improve-machinebumps the policy's on promotion. - A test-only variant built from the same factory (a loosened guard) gets its own
version("1-loose"), so its runs are never mistaken for the real machine's.
2. Pick a store
- Tests and local runs:
createInMemoryEventLogStore()from@statelyai/agent/log, or write each thread'sresult.eventsto a JSON file after the run. - Production: implement
AgentEventLogStoreagainst your database and check it with `assertEventLogStoreCo
Установить add-traces в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл add-traces?
Make every run of a @statelyai/agent or XState machine leave a replayable, stamped trace — an event log thread plus trace events — so evals and self-improvement can read what happened and what produced it. Use when asked to "add tracing", "add logging", "persist runs", "stamp traces", "record what the agent did", or "set up observability" for an agent machine, or before writing evals or improving a policy from traces.
Как установить скилл add-traces?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл add-traces запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic