Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AMAP ML SkillClaw summarize sessions parallel

From Leeroopedia
Knowledge Sources
Domains Session_Processing, LLM_Summarization
Last Updated 2026-10-22 00:00 GMT

Overview

Concrete tool for preprocessing and summarizing session recordings into compact dual-layer representations (lossless trajectory + LLM analysis), provided by the SkillClaw evolve server package.

Description

The summarize_sessions_parallel async function takes a list of raw session dicts and enriches each with three fields: `_trajectory` (a lossless programmatic step-by-step text trace built without LLM), `_summary` (an LLM-generated analysis of the session), and `_skills_referenced` (a set of skill names extracted from injected_skills and read_skills). It also computes `_avg_prm` and `_has_tool_errors`. All sessions are processed in parallel via `asyncio.gather`. This reduces raw session data from megabytes to tens-of-kilobytes, making downstream evolution prompts feasible.

Usage

Import and use when you need to:

  • Prepare raw session recordings for skill evolution
  • Build compact session representations for LLM prompts
  • Extract skill references and metadata from session data

Code Reference

Source Location

  • Repository: SkillClaw
  • File: `evolve_server/pipeline/summarizer.py:L414-464`

Signature

async def summarize_sessions_parallel(
    llm: AsyncLLMClient,
    sessions: list[dict],
) -> list[str]:
    """Preprocess and summarize all sessions in parallel.

    For each session:
    1. Extract metadata (_skills_referenced, _avg_prm, etc.)
    2. Build programmatic _trajectory (lossless)
    3. Generate _summary via LLM (trajectory-aware analysis)

    Returns the list of summary strings (same order as sessions).
    """

Import

from evolve_server.pipeline.summarizer import summarize_sessions_parallel

I/O Contract

Inputs

Name Type Required Description
llm AsyncLLMClient Yes Async OpenAI-compatible LLM client
sessions list[dict] Yes Raw session dicts with turns, tool_calls, tool_results

Outputs

Name Type Description
Returns list[str] Summary strings in same order as sessions
Side effects dict mutation Each session enriched with _trajectory, _summary, _skills_referenced, _avg_prm, _has_tool_errors

Usage Examples

Summarize Sessions

import asyncio
from evolve_server.core.llm_client import AsyncLLMClient
from evolve_server.pipeline.summarizer import summarize_sessions_parallel

llm = AsyncLLMClient(
    api_key="sk-...",
    base_url="https://api.openai.com/v1",
    model="gpt-4o",
)

sessions = [
    {"session_id": "sess-1", "turns": [{"prompt_text": "...", "response_text": "..."}]},
    {"session_id": "sess-2", "turns": [...]},
]

summaries = asyncio.run(summarize_sessions_parallel(llm, sessions))

for session in sessions:
    print(f"Session {session['session_id']}:")
    print(f"  Skills referenced: {session['_skills_referenced']}")
    print(f"  Trajectory length: {len(session['_trajectory'])} chars")
    print(f"  Summary length: {len(session['_summary'])} chars")
    print(f"  Avg PRM: {session['_avg_prm']}")

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment