Teich normalizes supported sources into structured training examples.
To write standalone OpenAI-style training JSONL from raw or extracted traces, run:
teich convert data --out teich-training.jsonlCore fields:
prompt: initial task descriptionfollow_up_prompts: optional additional user turns after the initial promptmessages: chat historytools: tool schemas available to the session, including tools that were not calledmetadata: session info, model, timestamps, usage, and provenance when available
messages follows an OpenAI-style chat shape:
[
{"role": "user", "content": "Build a todo app"},
{
"role": "assistant",
"content": "I will inspect the project.",
"tool_calls": [
{
"id": "call_1",
"type": "function",
"function": {
"name": "Read",
"arguments": {"file_path": "README.md"}
}
}
]
},
{"role": "tool", "tool_call_id": "call_1", "name": "Read", "content": "..."}
]Supported roles include:
systemdeveloperuserassistanttool
Assistant messages can include:
content: text responsereasoning_content: reasoning traces when the source provides themtool_calls: function calls with arguments
Some providers split a single model turn across multiple native events. Teich normalizes those fragments so semantic order is:
reasoning_content- optional assistant
content tool_calls
Reasoning that arrives after assistant text or a tool-call fragment is moved back in front of the output it explains.
tools contains function schemas available to the session:
[
{
"type": "function",
"function": {
"name": "Read",
"description": "Read a file.",
"parameters": {
"type": "object",
"properties": {
"file_path": {"type": "string"}
},
"required": ["file_path"],
"additionalProperties": true
}
}
}
]Teich preserves configured tool snapshots where the source provides them. This matters because a training row can need the tool schema even when the model did not call that tool.
Tool schema sources include:
- configured tools embedded in generated traces
- generated dataset
README.mdsnapshots tools.jsonsnapshots- native provider tool declarations
- fallback inference from observed tool calls when no explicit schema exists
Common metadata keys:
source_filesource_linesession_idtrace_typemodel_providermodelcwdcli_versionturn_countusagetotal_cost_usdfirst_message_timestamp
When the source format exposes per-message timestamps, converted rows include metadata.first_message_timestamp from the first timestamp-bearing source event that becomes a user message. It is not synthesized from session-start metadata.
Native Claude Code and Claude Desktop traces can contain runtime context that the model saw but that is not ordinary user text.
Teich preserves this as masked system messages and mirrors it into metadata.system_prompt.
Examples include:
- Claude Desktop skill listings
- MCP instruction deltas
- deferred tool declarations
- command permission context
- date changes
- hook context
- away summaries
- session recaps
Local slash-command artifacts such as /model are filtered. /goal contributes the actual user goal text. Queued prompts become real user turns.
Advertised native Claude Code / Claude Desktop tools receive schemas even when a tool is only declared through deferred-tool context.
The chat provider writes structured training rows directly instead of raw traces.
Single-turn rows can include:
messagespromptthinkingresponsemodel
Multi-turn follow-up rows can also include:
follow_up_promptsresponses- final
response
system is prompt-specific when provided. If a prompt row does not include system, Teich does not inject a default system prompt.
Rows ending on a tool result are incomplete without a follow-up assistant turn.
load_traces() drops those rows by default. Pass drop_incomplete_traces=False only when you intentionally want to inspect or repair them.
Generated datasets include a compact README.md with:
- Teich attribution
- row or file counts
- provider metadata when available; generated-run cards may also include model metadata
- a bounded example row
- links to the maintained training and data-preparation docs
- extraction guidance when the dataset came from
teich extract - a tool-schema summary when tools are available
Small tool snapshots are embedded in the dataset card. Large snapshots are written to tools.json so Hugging Face dataset-card validation does not have to process a massive YAML/Markdown payload.
The generated card intentionally avoids trainer-specific code blocks. Training APIs, model defaults, and library setup change over time; the maintained guidance lives in Training and Preparing Data.
When you want a trainer-ready JSONL file without relying on Teich formatting or masking at training time, run:
teich convert data --out teich-training.jsonlGenerated dataset guidance is produced by src/teich/trace_readme.py, so behavior changes should update both top-level docs and that template.