Agent skill

Save Trajectory

by AgentToolkit in AgentToolkit/altk-evolve

Save the current conversation as a trajectory JSON file in OpenAI chat completion format for analysis and fine-tuning

Apache-2.0Auto-check passedAI & LLM Engineering

Install Save Trajectory

skills CLI
$ npx skills add AgentToolkit/altk-evolve --skill save-trajectory -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install AgentToolkit/altk-evolve save-trajectory --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/AgentToolkit/altk-evolve.git skills-src && mkdir -p .claude/skills && cp -r skills-src/platform-integrations/codex/plugins/evolve-lite/skills/evolve-lite/save-trajectory .claude/skills/save-trajectory && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
save-trajectory
GitHub stars
122
Token cost
~1.4k tokens
SKILL.md length
580 words
Files
3 (incl. scripts)
Skills in repo
21
Repo updated
First seen
Licence
Apache-2.0

At a glance

Save the current conversation as a trajectory JSON file in OpenAI chat completion format for analysis and fine-tuning

  • Works in 5 steps: Walk Through Conversation Messages → Convert to OpenAI Chat Completion Format → Clean Content → …
  • Tasks that involve LLM API integration
  • SKILL.md covers Overview, Workflow, Example Output and Notes
  • Runs Python scripts from its folder; calls python3 and git

What it does

Save Trajectory is an agent skill from AgentToolkit/altk-evolve. Save the current conversation as a trajectory JSON file in OpenAI chat completion format for analysis and fine-tuning

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including scripts (for example `scripts/on_stop.py` and `scripts/save_trajectory.py`).

It sits in AI & LLM Engineering, covering LLM API integration and Fine-tuning. It works with OpenAI. The repository describes itself as: Self improving agents through iterations. The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve LLM API integration
  • Tasks that involve Fine-tuning

Example prompts

  • “/save-trajectory”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Walk Through Conversation Messages
  2. Convert to OpenAI Chat Completion Format
  3. Clean Content
  4. Build Envelope
  5. Save via Helper Script

What it can do on your machine

Read from SKILL.md and the folder at commit 9e5bb56. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python3
    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Save Trajectory loads about 1.4k tokens when it runs. Until then it costs about 33 tokens; SKILL.md has 580 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~33
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from AgentToolkit/altk-evolve at commit 9e5bb56, republished under its Apache-2.0 licence (© AgentToolkit). 580 words, ~1,423 tokens.

Download SKILL.mdSave it as .claude/skills/save-trajectory/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
save-trajectory
description
Save the current conversation as a trajectory JSON file in OpenAI chat completion format for analysis and fine-tuning

Save Trajectory

Overview

This skill saves the current session's conversation history as a JSON file in OpenAI chat completion format. The trajectory is saved to .evolve/trajectories/ in the project root. This enables trajectory analysis, fine-tuning data collection, and session review.

Workflow

Step 1: Walk Through Conversation Messages

Review all messages in the current conversation from start to finish. For each message, identify its type:

  • User text messages
  • Assistant text responses (may include thinking)
  • Assistant tool calls
  • Tool results
Step 2: Convert to OpenAI Chat Completion Format

Convert each message to the appropriate format:

User text message:

json
{"role": "user", "content": "the user's message text"}

Assistant text response (no thinking):

json
{"role": "assistant", "content": "the assistant's response text"}

Assistant text response (with thinking):

json
{"role": "assistant", "content": "the assistant's response text", "thinking": "the thinking/reasoning text"}

Assistant tool call (no visible text):

json
{
  "role": "assistant",
  "content": null,
  "tool_calls": [
    {
      "id": "tool_call_id_here",
      "type": "function",
      "function": {
        "name": "ToolName",
        "arguments": "{\"param\": \"value\"}"
      }
    }
  ]
}

Assistant tool call with text:

json
{
  "role": "assistant",
  "content": "text before/after the tool call",
  "tool_calls": [
    {
      "id": "tool_call_id_here",
      "type": "function",
      "function": {
        "name": "ToolName",
        "arguments": "{\"param\": \"value\"}"
      }
    }
  ]
}

Tool result:

json
{"role": "tool", "tool_call_id": "tool_call_id_here", "content": "the tool output text"}
Important Details
  • Tool call arguments must be a JSON string, not a nested object. Use json.dumps() on the arguments object.
  • Tool call IDs: Use the actual tool call ID from the conversation. If not available, generate a unique ID like call_001, call_002, etc.
  • Multiple tool calls: If the assistant made multiple tool calls in one turn, include all of them in a single assistant message's tool_calls array, followed by separate tool result messages for each.
  • Thinking blocks: If the assistant had both thinking and text in the same turn, combine them into one message with both content and thinking fields.
Step 3: Clean Content

Strip <system-reminder>...</system-reminder> tags and their contents from all message content. Use a non-greedy multiline match (e.g., re.sub(r'<system-reminder>[\s\S]*?</system-reminder>', '', text).strip()). If after stripping, a message has empty content and no tool calls, omit it.

Step 4: Build Envelope

Wrap the messages array in a trajectory envelope:

json
{
  "model": "<model-id-from-session>",
  "timestamp": "2025-01-15T10:30:00Z",
  "session_id": "<session-id-from-session>",
  "messages": [...]
}
  • model: Use the exact model ID from the current session's environment context (e.g., the value after "You are powered by the model named …"). Do not hardcode a default — always read it from the session.
  • timestamp: Current ISO 8601 timestamp
  • session_id: The current session identifier. Read it from whatever the harness exposes — the session_id passed into the skill, the session id surfaced in the session context, or a runtime-provided environment variable. Include it verbatim so offline provenance can match this trajectory to recall audit events for the same session. Omit the field only if no session id is truly available in this environment.
Show full SKILL.md (211 more words)Show less
Step 5: Save via Helper Script

Write the trajectory JSON to a temporary file using the Write tool, then pass the file path to the helper script:

  1. Write the JSON to .evolve/tmp/trajectory_input.json using the Write tool (create the directory if needed)
  2. Run the helper script with the file path as an argument:
bash
tmp=.evolve/tmp/trajectory_input.json; mkdir -p .evolve/tmp; trap 'rm -f "$tmp"' EXIT; python3 "$(git rev-parse --show-toplevel 2>/dev/null || pwd)/plugins/evolve-lite/skills/evolve-lite/save-trajectory/scripts/save_trajectory.py" "$tmp"

Important: Do NOT use inline Python scripts, heredocs, or stdin piping to pass the trajectory JSON. Always use the Write tool to create a temp file first. This avoids escaping issues with backslashes, quotes, and newlines in conversation content.

The script will:

  • Read the trajectory JSON from the provided file path
  • Create the .evolve/trajectories/ directory if needed
  • Generate a timestamped filename (trajectory_YYYY-MM-DDTHH-MM-SS.json)
  • Write the formatted JSON
  • Print confirmation with file path and message count

Example Output

After saving, you should see output like:

text
Trajectory saved: /path/to/project/.evolve/trajectories/trajectory_2025-01-15T10-30-00.json
Messages: 12

Notes

  • This skill captures what's visible in the current conversation context. Very long sessions may have earlier messages compressed or summarized by the system. Include these summarized messages as-is with role: "user" or role: "assistant" as appropriate — do not skip them, since they preserve the conversation flow.
  • The trajectory format is compatible with OpenAI chat completion format for downstream tooling.
  • Trajectories are saved per-project in .evolve/trajectories/ and can be version-controlled or gitignored as preferred.

© AgentToolkit, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (scripts) in platform-integrations/codex/plugins/evolve-lite/skills/evolve-lite/save-trajectory of AgentToolkit/altk-evolve.

  • SKILL.md
  • scripts/on_stop.py
  • scripts/save_trajectory.py

Open the folder on GitHubat commit 9e5bb56

Compare with similar skills

Save Trajectory next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Save Trajectory compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Save Trajectory this skillAgentToolkit/altk-evolve122—~1.4kAutomated safety check: PassApache-2.0
Azure AI Projects Python SDKmicrosoft/skills3.1k6 repos~2.8kAutomated safety check: PassMIT
Fine-Tuning ExpertJeffallan/claude-skills12k1 repos~1.7kAutomated safety check: PassMIT
Dingo VerifyMigoXLab/dingo757—~833Automated safety check: PassApache-2.0
Instructor Structured LLM OutputsOrchestra-Research/AI-Research-SKILLs13k7 repos~4.2kAutomated safety check: PassMIT
Openai Knowledgeopenai/openai-agents-python30k1 repos~408Automated safety check: PassMIT

Similar skills

  • Official

    Reference for building on Microsoft Foundry with the azure-ai-projects Python SDK: project clients, versioned agents, evaluations, connections, datasets and indexes.

    3.1k GitHub starsUsed in 6 repos~2.8k tokens
    AI & LLM EngineeringAuto-check passed
  • Fine-Tuning Expert

    Jeffallan/claude-skills

    Guides LLM fine-tuning with LoRA and QLoRA through Hugging Face PEFT, from dataset validation and training checks to adapter merging, quantization and deployment.

    12k GitHub starsUsed in 1 repo~1.7k tokens
    AI & LLM EngineeringAuto-check passed
  • Dingo Verify

    MigoXLab/dingo

    A skill your agent uses when the user wants to fact-check an article or verify factual claims in a document.

    757 GitHub stars~833 tokensUpdated 9 days ago
    AI & LLM EngineeringAuto-check passed
  • Instructor Structured LLM Outputs

    Orchestra-Research/AI-Research-SKILLs

    Shows how to pull validated, typed data out of LLM responses with Instructor and Pydantic models, including retries on failure and partial streaming.

    13k GitHub starsUsed in 7 repos~4.2k tokens
    AI & LLM EngineeringAuto-check passed
  • Openai Knowledge

    openai/openai-agents-python

    Official

    Retrieve authoritative OpenAI API and platform documentation when an integration or claim needs current external evidence.

    30k GitHub starsUsed in 1 repo~408 tokens
    AI & LLM EngineeringAuto-check passed
  • Installs Codex as an agent provider for NanoClaw groups, with streaming, MCP tools, server-side history and vault-only credentials, next to or instead of Claude.

    31k GitHub stars~2.3k tokensUpdated today
    AI & LLM EngineeringAuto-check: notes

More from AgentToolkit/altk-evolve

All 21 skills in this repo
  • Agent Wiki Compare Outcomes

    AgentToolkit/altk-evolve

    Contrasts successful and failed agent runs of the same task and derives guidelines backed by evidence from transcripts, tool calls and outcome judgments.

    122 GitHub stars~1.7k tokensUpdated today
    Auto-check passed
  • Trajectory Skill Synthesizer

    AgentToolkit/altk-evolve

    Turns a saved agent trajectory into a reusable skill with a SKILL.md and supporting scripts, so later sessions can call the workflow instead of rediscovering it.

    122 GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • Evolve Memory Mirror

    AgentToolkit/altk-evolve

    Copies a memory the agent just saved into the shared evolve store with a retrieval trigger, so it can be shared across a team and audited like other entities.

    122 GitHub stars~922 tokensUpdated today
    Auto-check passed
  • Agent Wiki Consult

    AgentToolkit/altk-evolve

    Has the agent read a project wiki's AGENTS.md and pull the guidelines that fit the task it is about to start, instead of loading the wiki at session start.

    122 GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Agent Wiki Guideline Extractor

    AgentToolkit/altk-evolve

    Reads a normalized Claude Code trajectory JSON and turns its errors and solutions into reusable guideline pages in wiki-twobatch/guidelines.

    122 GitHub stars~2k tokensUpdated today
    Auto-check passed
  • Agent Wiki Ingest

    AgentToolkit/altk-evolve

    Ingest one or more agent trajectories (raw bob/claude traces or normalized JSON) into an agent-wiki end-to-end — convert, summarize, extract guidelines, synthesize skills, optionally compare…

    122 GitHub stars~4k tokensUpdated today
    Auto-check passed

Works with

Questions about Save Trajectory

What does Save Trajectory do?

Save the current conversation as a trajectory JSON file in OpenAI chat completion format for analysis and fine-tuning. Save Trajectory is an agent skill from AgentToolkit/altk-evolve.

When should I use Save Trajectory?

Save Trajectory fits situations like: tasks that involve LLM API integration; tasks that involve Fine-tuning.

How do I install Save Trajectory in Claude Code?

Run `npx skills add AgentToolkit/altk-evolve --skill save-trajectory -a claude-code`. Or copy the skill folder (platform-integrations/codex/plugins/evolve-lite/skills/evolve-lite/save-trajectory in AgentToolkit/altk-evolve) into .claude/skills/save-trajectory in your project. Claude Code loads it when a task matches its description.

How do I install Save Trajectory in Codex?

Run `npx skills add AgentToolkit/altk-evolve --skill save-trajectory -a codex`. Or copy the skill folder (platform-integrations/codex/plugins/evolve-lite/skills/evolve-lite/save-trajectory in AgentToolkit/altk-evolve) into .agents/skills/save-trajectory in your project. Codex loads it when a task matches its description.

Can I use Save Trajectory in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add AgentToolkit/altk-evolve --skill save-trajectory -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/save-trajectory, .gemini/skills/save-trajectory, .github/skills/save-trajectory and .opencode/skills/save-trajectory in your project.

What does Save Trajectory need to run?

Going by SKILL.md and its folder, Save Trajectory needs Python for the scripts in its folder and the command-line tools its instructions call (python3 and git). Our summary lists: Python 3.

Does Save Trajectory access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Save Trajectory safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Save Trajectory use?

Save Trajectory is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Save Trajectory use?

About 1.4k tokens (SKILL.md is roughly 5.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Save Trajectory?

Skills that share tags, products or a category with Save Trajectory: Azure AI Projects Python SDK (microsoft/skills, 3.1k stars), Fine-Tuning Expert (Jeffallan/claude-skills, 12k stars), Dingo Verify (MigoXLab/dingo, 757 stars) and Instructor Structured LLM Outputs (Orchestra-Research/AI-Research-SKILLs, 13k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Save Trajectory?

AgentToolkit (a GitHub organization) maintains it in AgentToolkit/altk-evolve, which has 122 GitHub stars. The repository holds 21 skills in this directory. The repository was last updated on October 7, 2026.

Source: AgentToolkit/altk-evolve on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.