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:2akouwu Reverify parse claims

From Leeroopedia
Knowledge Sources
Domains LLM_Parsing, Data_Structures
Last Updated 2026-10-24 12:00 GMT

Overview

Concrete tool for extracting a JSON array of claim dicts from a model's free-form text response, tolerantly handling code fences and stray prose, provided by the Reverify library.

Description

The parse_claims function pulls claim objects out of a model response that may contain code fences (```json ... ```), stray prose, or a single dict instead of an array. It strips code fences, finds the outermost JSON array ([ ... ]), parses it, and filters to dicts that have a kind field. Returns an empty list on parse failure — never raises.

Usage

Import this function when you need to:

  • Parse a model's response into claim dicts for Claim.from_dict.
  • Handle code-fenced or prose-contaminated model output tolerantly.

Code Reference

Source Location

  • Repository: Reverify
  • File: reverify/agent.py
  • Lines: L221-239

Signature

def parse_claims(raw: str) -> List[Dict[str, Any]]:
    """Pull a JSON array of claim dicts out of a model response."""

Import

from reverify.agent import parse_claims

I/O Contract

Inputs

Name Type Required Description
raw str Yes Model response text (may contain code fences, prose)

Outputs

Name Type Description
return List[Dict] List of claim dicts with "kind" field; empty list on failure

Usage Examples

Parse a Clean Response

from reverify.agent import parse_claims

raw = '[{"kind": "bytes_at", "params": {"offset": 40, "expected": "554889e5"}}]'
claims = parse_claims(raw)
# [{"kind": "bytes_at", "params": {"offset": 40, "expected": "554889e5"}}]

Parse a Code-Fenced Response

raw = '''Here are my claims:
```json
[{"kind": "import_present", "params": {"name": "CreateFileW"}}]
```
'''
claims = parse_claims(raw)  # handles the fence and prose

Related Pages

Implements Principle

Page Connections

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