Principle:AMAP ML SkillClaw Session Recording
| Knowledge Sources | |
|---|---|
| Domains | Observability, Session_Tracking |
| Last Updated | 2026-10-22 00:00 GMT |
Overview
A session recording pattern that captures per-turn conversation data (prompts, responses, tool calls, injected skills, PRM scores) from LLM proxy traffic for later skill evolution.
Description
Session recording addresses the problem of collecting evidence for skill evolution from live agent interactions. The SkillClaw pattern buffers per-turn data in memory as the proxy processes each request, flushing to JSONL files (`conversations.jsonl` and `prm_scores.jsonl`) when turns are finalized. Each turn record includes: prompt text, response text, reasoning content, tool calls, tool results, read/modified skills, injected skill names, and PRM scores. Complete sessions are uploaded to shared storage for the evolution pipeline to consume.
Usage
Use this principle when designing systems that need:
- Conversation logging for post-hoc analysis
- Evidence collection for ML-driven skill evolution
- Per-turn tracking of tool usage and skill interactions
- Asynchronous session upload to shared storage
Theoretical Basis
The recording pattern uses lazy buffering:
- Per-turn buffer: Each turn is buffered in memory (not written immediately)
- Flush on boundary: When the next turn arrives or the session closes, the previous turn is finalized
- Dual output: Conversation data → `conversations.jsonl`, PRM scores → `prm_scores.jsonl`
- Session assembly: Individual turns are accumulated into a session list for upload
# Abstract algorithm (NOT real implementation)
def handle_turn(session_id, turn_num, prompt, response, tool_calls, skills):
turn_record = {
"turn_num": turn_num,
"prompt_text": prompt,
"response_text": response,
"tool_calls": tool_calls,
"injected_skills": skills,
"prm_score": None, # Filled asynchronously
}
session_turns[session_id].append(turn_record)
buffer_to_flush(session_id, turn_record)
def on_session_close(session_id):
flush_pending_records(session_id)
upload_session_to_storage(session_turns[session_id])