Skip to main content
Glama

export_dpo_pairs

Destructive

Extract DPO preference pairs from local memory logs to enable direct preference optimization for AI model training.

Instructions

Export DPO preference pairs from local memory log

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memoryLogPathNo

Implementation Reference

  • The handler function `buildExportDpoResponse` in `adapters/mcp/server-stdio.js` implements the `export_dpo_pairs` tool, which takes memories and exports DPO JSONL triples.
    function buildExportDpoResponse(args = {}) {
      let memories = [];
    
      if (args.inputPath) {
        const inputPath = resolveSafePath(args.inputPath, { mustExist: true });
        const raw = fs.readFileSync(inputPath, 'utf-8');
        const parsed = JSON.parse(raw);
        memories = Array.isArray(parsed) ? parsed : parsed.memories || [];
      } else {
        const memoryLogPath = args.memoryLogPath
          ? resolveSafePath(args.memoryLogPath, { mustExist: true })
          : DEFAULT_LOCAL_MEMORY_LOG;
        memories = readJSONL(memoryLogPath);
      }
    
      const result = exportDpoFromMemories(memories);
      if (args.outputPath) {
        const outputPath = resolveSafePath(args.outputPath);
        fs.mkdirSync(path.dirname(outputPath), { recursive: true });
        fs.writeFileSync(outputPath, result.jsonl);
      }
    
      return toTextResult({
        pairs: result.pairs.length,
        errors: result.errors.length,
        learnings: result.learnings.length,
        unpairedErrors: result.unpairedErrors.length,
        unpairedLearnings: result.unpairedLearnings.length,
        outputPath: args.outputPath ? resolveSafePath(args.outputPath) : null,
      });
    }
  • The logic for exporting DPO pairs from memories is implemented in `exportDpoFromMemories` in `scripts/export-dpo-pairs.js`.
    function exportDpoFromMemories(memories) {
      const errors = memories.filter((m) => m.category === 'error');
      const learnings = memories.filter((m) => m.category === 'learning');
      const result = buildDpoPairs(errors, learnings);
    
      const traces = result.pairs.map((pair) => traceForDpoPair(pair));
      const reasoning = aggregateTraces(traces);
    
      const pairsWithTraces = result.pairs.map((pair, i) => ({
        ...pair,
        metadata: {
          ...pair.metadata,
          reasoningTrace: {
            traceId: traces[i].traceId,
            confidence: traces[i].summary.confidence,
            passed: traces[i].summary.passed,
            verified: traces[i].summary.verified,
            refuted: traces[i].summary.refuted,
            edgeCases: traces[i].edgeCases,
          },
        },
      }));
    
      return {
        pairs: pairsWithTraces,
        unpairedErrors: result.unpairedErrors,
        unpairedLearnings: result.unpairedLearnings,
        errors,
        learnings,
        reasoning,
        jsonl: toJSONL(pairsWithTraces),
      };
    }
  • The `export_dpo_pairs` tool is registered in the switch block of the `callToolInner` function within `adapters/mcp/server-stdio.js`.
    case 'export_dpo_pairs':
      return buildExportDpoResponse(args);
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The annotations provide destructiveHint=true, indicating this is a potentially destructive operation. The description adds context about what gets exported ('DPO preference pairs') and the source ('local memory log'), which is useful behavioral information beyond the annotation. However, it doesn't address other important behavioral aspects like authentication needs, rate limits, or what 'destructive' specifically means in this context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just 6 words, with zero wasted language. Every word contributes directly to understanding the tool's purpose. It's perfectly front-loaded with the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with destructiveHint=true, no output schema, and 0% parameter documentation, the description is insufficiently complete. It doesn't explain what 'export' means operationally, what format the output takes, what happens to the source data (given the destructive hint), or provide any parameter guidance. The description leaves too many critical questions unanswered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage for the single parameter 'memoryLogPath', the description provides no information about this parameter. It doesn't explain what a memory log path is, what format it should take, or provide any examples. The description fails to compensate for the complete lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Export') and the resource ('DPO preference pairs from local memory log'), providing a specific verb+resource combination. However, it doesn't differentiate this tool from its many siblings, particularly other export-like tools such as 'export_databricks_bundle'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With 28 sibling tools including other export operations, there's no indication of prerequisites, appropriate contexts, or exclusions that would help an agent choose correctly.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/IgorGanapolsky/mcp-memory-gateway'

If you have feedback or need assistance with the MCP directory API, please join our Discord server