Commit 48acc24
committed
Address PR #1399 review: threshold margin, docs, NO_FINAL wording, doc-agent test
Resolves the demonstrably actionable items from the latest code review:
* TOOL_LOOP_THRESHOLD bumped from 3 to 4 to keep a strict margin over
STRUCTURED_OUTPUT_RETRIES. The previous comment said "Keep >="
but the values were equal — pydantic-ai's output_retries only
governs final_result retries today, not regular tool calls, so the
earlier 3==3 was not a runtime bug, but the margin makes the guard
defensible if pydantic-ai ever extends retry coverage. Tests now
derive the boundary from the constant via ``range(TOOL_LOOP_THRESHOLD)``
so future tweaks can't silently invalidate the boundary cases.
* ``_failure_message_for_classification`` for ``no_final_response`` no
longer reads "the model exhausted its tool-use budget" — that phrase
implies tool use happened, but the same classification fires when
the model only emitted narrative text with no tools at all. Reworded
to cover both sub-cases (text-only / budget-exhausted).
* Removed misleading ``# pragma: no cover`` on the deliberate
``__str__`` raiser in ``test_unhashable_args_fall_back_to_repr``.
``json.dumps(..., default=str)`` does invoke ``str(bad)`` →
``__str__`` at runtime, so the line is genuinely covered; the
pragma was contradicting its own "exercised via default=str"
comment. Replaced with a clarifying comment.
* CHANGELOG entry adds an explicit cost note: bumping ``output_retries``
from 1 to 3 means a previously-failing Anthropic cell can now incur
up to 3 result-tool round trips. That's the correct tradeoff
(the prior baseline returned None and produced no answer), but
operators tracking Anthropic billing should anticipate the shift.
Also corrected the constant reference (DEFAULT_EXTRACT_MODEL, not
the now-removed EXTRACT_DEFAULT_MODEL) and updated the
TOOL_LOOP_THRESHOLD wording to reflect the new value.
* New ``test_document_agent_inherits_anthropic_temperature_guard`` in
``test_pydantic_ai_agents.py`` covers the inheritance path the
reviewer flagged: ``PydanticAIDocumentAgent._structured_response_raw``
must also force ``temperature=0`` for Anthropic models. The
base-class test already covered the implementation, but a future
override on a subclass could silently regress without an explicit
document-agent assertion.
* Updated ``test_core_agent_base_structured_prompt_commits_to_result``
to assert on the merged prompt's actual wording — the old
"genuinely cannot be found" phrase was replaced during the
origin/main merge with "Only return null/None after multiple
search attempts". Now asserts on ``SEARCH PROTOCOL`` and
``multiple search attempts``.
Skipped: review issue #2 (two-step Anthropic temperature mechanism)
is already addressed by the merge — ``extract_model`` and
``extract_temperature = _resolve_extract_temperature(extract_model)``
now sit adjacent in ``doc_extract_query_task`` with an explicit
"in lock-step with whichever model family will actually run" comment,
which is what the reviewer asked for.1 parent 2c20d67 commit 48acc24
5 files changed
Lines changed: 112 additions & 29 deletions
File tree
- opencontractserver
- constants
- tasks
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
44 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
Lines changed: 10 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 88 | + | |
92 | 89 | | |
93 | 90 | | |
94 | 91 | | |
95 | | - | |
| 92 | + | |
96 | 93 | | |
97 | 94 | | |
98 | 95 | | |
99 | 96 | | |
100 | 97 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
| 98 | + | |
105 | 99 | | |
106 | 100 | | |
107 | 101 | | |
108 | 102 | | |
109 | 103 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 104 | + | |
114 | 105 | | |
115 | 106 | | |
116 | 107 | | |
| |||
188 | 179 | | |
189 | 180 | | |
190 | 181 | | |
191 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
192 | 187 | | |
193 | 188 | | |
194 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1517 | 1517 | | |
1518 | 1518 | | |
1519 | 1519 | | |
1520 | | - | |
| 1520 | + | |
| 1521 | + | |
1521 | 1522 | | |
1522 | 1523 | | |
1523 | | - | |
1524 | | - | |
1525 | | - | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
1526 | 1531 | | |
1527 | 1532 | | |
1528 | 1533 | | |
| |||
1554 | 1559 | | |
1555 | 1560 | | |
1556 | 1561 | | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
0 commit comments