## TL;DR
Twelve thousand lines timing out usually means every line pays parsing cost before matching starts, and the parser is failing on the real format, retrying or erroring per line. Collect a sample of memos and read their actual structure: position of reference, separator style, check numbers, and reference types. Build the parser for that structure with fast paths for the common shapes and a safe fallback that marks memos unparsed instead of stalling. Matching then proceeds on parsed references plus the original memo text.

```text
agent could not parse the bank memo format and the match loop timed out on 12k lines
```

## Use this when
- The match loop times out specifically during memo parsing on thousands of lines, here 12k.
- Memo formats include codes, separators, or structures the parser does not expect.
- Some lines parse instantly and others hang or error, pointing at format-dependent paths.

## Not for this skill when
- Memos are missing or empty on most lines. Then matching must use other fields; parsing cannot be fixed for data that does not exist.
- Parsing succeeds but matching still times out. That is the matching-scale problem, handled by blocking and staging.

## Steps
1. Sample a few hundred memos across vendors and days and classify their shapes: reference positions, separators, and token types. Verify: the dominant shapes cover most of the 12k lines
2. Time the current parser on the sample and identify the expensive or failing shapes. Verify: the slow path is tied to specific shapes, not to volume alone
3. Build the parser for the actual shapes with fast exact extraction for the common ones and a bounded, no-retry fallback for the rest. Verify: every sample memo parses or is marked unparsed within a small time budget
4. Run matching on parsed references with the original memo retained as a fallback signal. Verify: match rates improve and no line stalls the run
5. Process the full 12k lines within the time budget with unparsed memos reported as an exception class. Verify: the run completes and the unparsed rate is quantified for the next parser iteration

## Variant phrasings
### bank memo format parse failed agent match timeout
The unparseable-memo phrasing.
### agent transaction memo parser bank reference extraction
When building the parser.

Compatibility: Bank memo and reference formats parsed by agent matching pipelines for 10k-plus line sets.

## Why it happens
Bank memos are the bank's idea of a description, not a data format: conventions vary by bank, channel, and even branch, mixing references, codes, and narrative in one string. Parsers written for one bank's format fail on another's, and per-line exception handling that logs verbosely or retries turns a format gap into a timeout. The sample-first approach works because memo formats are stable per bank: learn the real shapes once and the whole set yields.

## Edge cases / pitfalls
- Keep the raw memo text through the pipeline; it is the evidence of last resort and the training data for the next parser version.
- Reference positions can shift when banks change memo layouts without notice; a periodic format re-check catches drift.
- Some memos carry check numbers or card tokens that are sensitive in logs; parse them but redact them in job logging.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_GDmSmT7QUBbJFefuyWuCBA
