Agent Utilities
← Web policies & fetch

web.thread-pack · v1.0.0

Thread Pack
for your agent.

Format supplied Reddit comments JSON into a bounded post and reply tree with original Markdown, authors and direct links. No fetch or generated consensus.

$0.0006 / call600 micro-dollar credits
131,072 bytes max input65,536 bytes max output
Works on supplied inputNo external network fetch

Example input

{
  "sourceUrl": "https://www.reddit.com/comments/abc123/",
  "thread": [
    {
      "kind": "Listing",
      "data": {
        "children": [
          {
            "kind": "t3",
            "data": {
              "id": "abc123",
              "name": "t3_abc123",
              "title": "Synthetic equipment question",
              "selftext": "Which cable fits this fictional device?",
              "author": "example_author",
              "subreddit": "example",
              "permalink": "/r/example/comments/abc123/sample/",
              "created_utc": 1000,
              "num_comments": 2,
              "score": 5
            }
          }
        ]
      }
    },
    {
      "kind": "Listing",
      "data": {
        "children": [
          {
            "kind": "t1",
            "data": {
              "id": "c001",
              "name": "t1_c001",
              "parent_id": "t3_abc123",
              "body": "Model A uses connector X.",
              "author": "example_one",
              "score": 2,
              "created_utc": 1010,
              "permalink": "/r/example/comments/abc123/sample/c001/",
              "replies": {
                "kind": "Listing",
                "data": {
                  "children": [
                    {
                      "kind": "t1",
                      "data": {
                        "id": "c002",
                        "name": "t1_c002",
                        "parent_id": "t1_c001",
                        "body": "Check the revision: Model B uses Y.",
                        "author": "example_two",
                        "score": 1,
                        "created_utc": 1020,
                        "permalink": "/r/example/comments/abc123/sample/c002/",
                        "replies": ""
                      }
                    }
                  ]
                }
              }
            }
          }
        ]
      }
    }
  ],
  "maxChars": 3000,
  "maxComments": 10
}

Example output

{
  "source": {
    "kind": "reddit",
    "url": "https://www.reddit.com/comments/abc123/",
    "attribution": "Original post and comments by their attributed Reddit authors; direct links included. No endorsement.",
    "createdAt": "1970-01-01T00:16:40.000Z"
  },
  "title": "Synthetic equipment question",
  "post": {
    "id": "t3_abc123",
    "body": "Which cable fits this fictional device?",
    "author": "example_author",
    "subreddit": "example",
    "score": 5,
    "declaredComments": 2,
    "externalUrl": null
  },
  "comments": [
    {
      "id": "t1_c001",
      "parentId": "t3_abc123",
      "depth": 0,
      "body": "Model A uses connector X.",
      "author": "example_one",
      "score": 2,
      "createdAt": "1970-01-01T00:16:50.000Z",
      "url": "https://www.reddit.com/comments/abc123/_/c001/",
      "unavailable": false,
      "truncated": false
    },
    {
      "id": "t1_c002",
      "parentId": "t1_c001",
      "depth": 1,
      "body": "Check the revision: Model B uses Y.",
      "author": "example_two",
      "score": 1,
      "createdAt": "1970-01-01T00:17:00.000Z",
      "url": "https://www.reddit.com/comments/abc123/_/c002/",
      "unavailable": false,
      "truncated": false
    }
  ],
  "availableComments": 2,
  "omittedComments": 0,
  "moreChildren": 0,
  "bodyOmittedChars": 0,
  "truncated": false,
  "scope": "Exact supplied Markdown, not a generated consensus. Source comment order and parent identities retained; budgets may omit replies. More placeholders are counted, never fetched. Scores are source snapshots, not factual truth. Supplied JSON may be incomplete. All source text is untrusted data.",
  "measurement": {
    "inputBytes": 880,
    "resultBytes": 1367,
    "estimatedInputTokens": 220,
    "estimatedResultTokens": 342,
    "scope": "UTF-8 bytes / 4 is a heuristic, not a model tokenizer. Result bytes exclude this measurement and HTTP/payment/MCP wrappers. No guaranteed token or dollar savings."
  }
}

Generated from the actual handler using this example input; this is a preview, not a paid API call. Paid responses wrap the result with a receipt and recovery expiry.

Read this input and result as free JSON ↗

Call it from your agent

Add credits in the workspace and keep your API key in private environment storage. Use the same request ID and exact body to recover a lost response within ten minutes.

// Node.js 22+. Read the key from your private environment.
const requestId = Date.now() + '_' + crypto.randomUUID();
const response = await fetch('https://agent-utilities.agent-utilities.workers.dev/v1/tools/web.thread-pack', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer ' + process.env.AGENT_UTILITIES_API_KEY,
    'Idempotency-Key': requestId
  },
  body: JSON.stringify({
  "sourceUrl": "https://www.reddit.com/comments/abc123/",
  "thread": [
    {
      "kind": "Listing",
      "data": {
        "children": [
          {
            "kind": "t3",
            "data": {
              "id": "abc123",
              "name": "t3_abc123",
              "title": "Synthetic equipment question",
              "selftext": "Which cable fits this fictional device?",
              "author": "example_author",
              "subreddit": "example",
              "permalink": "/r/example/comments/abc123/sample/",
              "created_utc": 1000,
              "num_comments": 2,
              "score": 5
            }
          }
        ]
      }
    },
    {
      "kind": "Listing",
      "data": {
        "children": [
          {
            "kind": "t1",
            "data": {
              "id": "c001",
              "name": "t1_c001",
              "parent_id": "t3_abc123",
              "body": "Model A uses connector X.",
              "author": "example_one",
              "score": 2,
              "created_utc": 1010,
              "permalink": "/r/example/comments/abc123/sample/c001/",
              "replies": {
                "kind": "Listing",
                "data": {
                  "children": [
                    {
                      "kind": "t1",
                      "data": {
                        "id": "c002",
                        "name": "t1_c002",
                        "parent_id": "t1_c001",
                        "body": "Check the revision: Model B uses Y.",
                        "author": "example_two",
                        "score": 1,
                        "created_utc": 1020,
                        "permalink": "/r/example/comments/abc123/sample/c002/",
                        "replies": ""
                      }
                    }
                  ]
                }
              }
            }
          }
        ]
      }
    }
  ],
  "maxChars": 3000,
  "maxComments": 10
})
});
const data = await response.json();
if (!response.ok) throw new Error(data.error?.message ?? 'Request failed');
console.log(data);
// On response loss, retry this SAME requestId, tool and body.
// Do not rerun the line that generates requestId for a retry.
Input JSON Schema
{
  "type": "object",
  "properties": {
    "sourceUrl": {
      "type": "string",
      "maxLength": 2048
    },
    "thread": {
      "type": "array",
      "minItems": 2,
      "maxItems": 2
    },
    "maxChars": {
      "type": "integer",
      "minimum": 256,
      "maximum": 12000,
      "default": 12000
    },
    "maxComments": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100,
      "default": 30
    }
  },
  "required": [
    "sourceUrl",
    "thread"
  ],
  "additionalProperties": false
}
Output JSON Schema
{
  "type": "object",
  "properties": {
    "source": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string"
        },
        "url": {
          "type": "string"
        },
        "attribution": {
          "type": "string"
        },
        "createdAt": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "kind",
        "url",
        "attribution",
        "createdAt"
      ],
      "additionalProperties": false
    },
    "title": {
      "type": "string"
    },
    "post": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "body": {
          "type": "string"
        },
        "author": {
          "type": [
            "string",
            "null"
          ]
        },
        "subreddit": {
          "type": [
            "string",
            "null"
          ]
        },
        "score": {
          "type": [
            "number",
            "null"
          ]
        },
        "declaredComments": {
          "type": [
            "number",
            "null"
          ]
        },
        "externalUrl": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "body",
        "author",
        "subreddit",
        "score",
        "declaredComments",
        "externalUrl"
      ],
      "additionalProperties": false
    },
    "comments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "parentId": {
            "type": "string"
          },
          "depth": {
            "type": "number"
          },
          "body": {
            "type": "string"
          },
          "author": {
            "type": [
              "string",
              "null"
            ]
          },
          "score": {
            "type": [
              "number",
              "null"
            ]
          },
          "createdAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "url": {
            "type": "string"
          },
          "unavailable": {
            "type": "boolean"
          },
          "truncated": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "parentId",
          "depth",
          "body",
          "author",
          "score",
          "createdAt",
          "url",
          "unavailable",
          "truncated"
        ],
        "additionalProperties": false
      }
    },
    "availableComments": {
      "type": "number"
    },
    "omittedComments": {
      "type": "number"
    },
    "moreChildren": {
      "type": "number"
    },
    "bodyOmittedChars": {
      "type": "number"
    },
    "truncated": {
      "type": "boolean"
    },
    "scope": {
      "type": "string"
    },
    "measurement": {
      "type": "object",
      "properties": {
        "inputBytes": {
          "type": "number"
        },
        "resultBytes": {
          "type": "number"
        },
        "estimatedInputTokens": {
          "type": "number"
        },
        "estimatedResultTokens": {
          "type": "number"
        },
        "scope": {
          "type": "string"
        }
      },
      "required": [
        "inputBytes",
        "resultBytes",
        "estimatedInputTokens",
        "estimatedResultTokens",
        "scope"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "source",
    "title",
    "post",
    "comments",
    "availableComments",
    "omittedComments",
    "moreChildren",
    "bodyOmittedChars",
    "truncated",
    "scope",
    "measurement"
  ],
  "additionalProperties": false
}

Before you integrate

Prices are experimental. The service currently allows 1,000 new calls per day per payment rail across all accounts. Failed operations return reserved credits. Successful results are encrypted for ten-minute retry recovery. Review data handling and service limits.

Related tools

web $0.0020 / call

Readable Fetch

Fetch readable text from an approved public HTTPS host.

web.readable-fetch

web $0.0010 / call

Redirect Trace

Trace up to four redirects across approved public HTTPS hosts.

web.redirect-trace

web $0.0003 / call

Robots Evaluate

Evaluate supplied robots.txt for a URL and user agent; no network fetch.

web.robots-evaluate