Skip to content

Commit 34b4bc4

Browse files
cosminachoclaude
andcommitted
test(langchain): switch invoice fixture to whole-dollar amount
Bedrock-hosted Claude and a few Gemini configs reliably OCR the invoice text from images but drop the decimal point: "$1234.56" comes back as `total_amount=123456.0`. That made 29 of the new file-input tests deterministically fail on Bedrock images and flaky on Gemini thinking runs. Switching the fixture amount to a whole-dollar value ($4200) removes the ambiguity entirely. Pydantic still coerces to `float`, so the schema field and assertion are unchanged. Regenerated all 11 committed fixture files and re-recorded the affected cassettes. Full file-input run: 364 passed, 318 skipped, 0 failed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e345310 commit 34b4bc4

13 files changed

Lines changed: 13 additions & 9 deletions

File tree

tests/cassettes.db

816 KB
Binary file not shown.

tests/langchain/file_fixtures.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@
2525

2626
INVOICE_NUMBER = "INV-7421"
2727
CUSTOMER = "Acme Corp"
28-
TOTAL_AMOUNT = 1234.56
28+
# Whole-dollar amount on purpose: when rendered into an image, OCR sometimes
29+
# drops the decimal point of values like "$1234.56" and the model then returns
30+
# 123456.0 instead of 1234.56 (observed on Bedrock-hosted Claude and flaky
31+
# Gemini thinking runs). An integer total sidesteps the ambiguity.
32+
TOTAL_AMOUNT = 4200
2933
DUE_DATE = "2026-03-15"
3034

3135
INVOICE_TEXT = (
3236
f"Invoice Number: {INVOICE_NUMBER}\n"
3337
f"Customer: {CUSTOMER}\n"
34-
f"Total Amount: ${TOTAL_AMOUNT:.2f}\n"
38+
f"Total Amount: ${TOTAL_AMOUNT}\n"
3539
f"Due Date: {DUE_DATE}\n"
3640
)
3741

@@ -55,7 +59,7 @@ def make_md() -> bytes:
5559
"# Invoice\n\n"
5660
f"- **Invoice Number:** {INVOICE_NUMBER}\n"
5761
f"- **Customer:** {CUSTOMER}\n"
58-
f"- **Total Amount:** ${TOTAL_AMOUNT:.2f}\n"
62+
f"- **Total Amount:** ${TOTAL_AMOUNT}\n"
5963
f"- **Due Date:** {DUE_DATE}\n"
6064
)
6165
return body.encode("utf-8")
@@ -67,7 +71,7 @@ def make_csv() -> bytes:
6771
writer.writerow(["field", "value"])
6872
writer.writerow(["invoice_number", INVOICE_NUMBER])
6973
writer.writerow(["customer", CUSTOMER])
70-
writer.writerow(["total_amount", f"{TOTAL_AMOUNT:.2f}"])
74+
writer.writerow(["total_amount", str(TOTAL_AMOUNT)])
7175
writer.writerow(["due_date", DUE_DATE])
7276
return buf.getvalue().encode("utf-8")
7377

@@ -78,7 +82,7 @@ def make_html() -> bytes:
7882
"<h1>Invoice</h1>"
7983
f"<p>Invoice Number: <strong>{INVOICE_NUMBER}</strong></p>"
8084
f"<p>Customer: {CUSTOMER}</p>"
81-
f"<p>Total Amount: ${TOTAL_AMOUNT:.2f}</p>"
85+
f"<p>Total Amount: ${TOTAL_AMOUNT}</p>"
8286
f"<p>Due Date: {DUE_DATE}</p>"
8387
"</body></html>"
8488
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
field,value
22
invoice_number,INV-7421
33
customer,Acme Corp
4-
total_amount,1234.56
4+
total_amount,4200
55
due_date,2026-03-15
-3 Bytes
Binary file not shown.
-85 Bytes
Loading
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html><body><h1>Invoice</h1><p>Invoice Number: <strong>INV-7421</strong></p><p>Customer: Acme Corp</p><p>Total Amount: $1234.56</p><p>Due Date: 2026-03-15</p></body></html>
1+
<!DOCTYPE html><html><body><h1>Invoice</h1><p>Invoice Number: <strong>INV-7421</strong></p><p>Customer: Acme Corp</p><p>Total Amount: $4200</p><p>Due Date: 2026-03-15</p></body></html>
-241 Bytes
Loading

tests/langchain/fixtures/files/invoice.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
- **Invoice Number:** INV-7421
44
- **Customer:** Acme Corp
5-
- **Total Amount:** $1234.56
5+
- **Total Amount:** $4200
66
- **Due Date:** 2026-03-15
-2 Bytes
Binary file not shown.
-232 Bytes
Loading

0 commit comments

Comments
 (0)