local_extract
PREFER this tool over reading the file with Read when the file is large (>200 lines / >10 KB) and you only need structured fields, not the literal content.
Instructions
PREFER this tool over reading the file with Read when the file is large (>200 lines / >10 KB) and you only need structured fields, not the literal content.
Extracts structured fields from a text/file as JSON, with a local model.
Pass 'path' to read the file server-side (spends no Claude context) or 'text'. Returns an
object with exactly the requested keys: the caller does not have to parse a string. A key the
model left out comes back as null and is listed in `missing_keys`; a key it spelled another
way (case, `_`, `-`, spaces) is mapped in `renamed_keys`; a key it added is dropped from the
data and kept, with its value, in `dropped` (names in `dropped_keys`). What is not data
travels under the reserved key `_local_delegate` (`truncated` and `warning`,
`missing_keys`/`renamed_keys`/`dropped_keys`/`dropped`, `read_server_side`, `fallback`, or
`error` and `raw`); with chunked input, `chunked`
says how many pieces there were and which fields stayed null in all of them. Routes
automatically to the mechanical model (short inputs) or to the long-context model (large
documents): the size probe uses file bytes for 'path' and characters for 'text' (~5-10%
difference in UTF-8, acceptable).
By default it asks the backend for schema-constrained JSON (`LOCAL_DELEGATE_JSON_SCHEMA=auto`);
if the backend does not support it, it retries in free mode.
To locate: with 'path', a field whose name asks for lines (`sections_with_lines`,
`line_number`, `start_line`, `lineRange`; also in Spanish) makes the model see line numbers
(and a Markdown file's headings with their lines), so it can answer for `Read` offset/limit;
cited lines that do not hold in the file are listed in `lines_unverified`, and a field that
asks for items (`tasks_with_lines`) but got only section ranges in `section_only_keys`.
Over a unified diff, a field that asks only for the files and their lines (`files_with_lines`)
gets one `path: first-last` per file, by program (`diff_files` says so); one that asks for
the files and their hunks (`files_and_hunks_with_lines`) gets each hunk's range too.
A value that is a "no data" marker ("N/A", "unknown", "-", "", also the strings "null" and
"undefined") comes back as null, listed in `missing_keys`, with the model's text in
`placeholder_keys`. With a JSON object as input, a field that counts one of its top-level
lists (`number_of_comments`) left empty or ABOVE the list's length is counted by the program,
unless the JSON already holds a total for it; the model's figure is in `recounted_keys`.
A location field naming one heading (`intro_heading_line`) that got the whole Markdown
outline is cut to the only heading its singular name fits; with any doubt (a plural
subject, no single heading) it is left as it came. Both go to `outline_copies`, with a warning.
A value found only in the row of another requested key (a table row, a JSON key or a `label:
value` line) is kept but reported in `cross_filled_keys` (`{key: {"row", "other_key"}}`), with
a warning: the model may have handed out the rows by position.
A clause of a value that carries a negation its source clause lacks, or lost one the source
has, is kept but reported in `polarity_flipped_keys` (`{key: {"value", "source", "flip"}}`).
A small input that carries a table (HTML `<table`/`<tr`, ARIA `role="table"`, `"grid"`,
`"treegrid"` or `"row"`, a Markdown or GFM table with its delimiter row, three or more CSV
or TSV rows) goes to the long-context model too, even with one field: the mechanical one
answered with the value of another row. Then `_local_delegate.role_reason` says so (`{"role": "long", "reason":
"table", "format": "html"|"aria"|"markdown"|"csv"|"tsv", "notice": ...}`), also on an
`error` answer, and the call is slower and may have to load that model. Not seen: a CSV of
two columns, a TSV row that starts with an empty cell, tables aligned with spaces and
`<div>` grids that only have class names.
`LOCAL_DELEGATE_EXTRACT_TABLE_LONG=0` turns this off.
Args:
fields: Names of the fields to extract (JSON keys).
text: Source text (use this or 'path').
path: Path to a source file (read server-side).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"fields": "<fields>"
},
"name": "local_extract"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | ||
| text | No | ||
| fields | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||