test(providers): add failing scenario for silent token-count exception swallowing #10889
No reviewers
Labels
No labels
auto/needs-reevaluation
controller-managed
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cleveragents/cleveragents-core!10889
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "tdd/m3-token-count-silent-failure"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
This PR adds a TDD issue-capture test for bug #10395.
The
_estimate_token_usage()method inLangChainChatProvidercontains a bareexcept Exception: return 0block that silently swallows any exception raised by the LLM'sget_num_tokens()call, returning0instead of propagating the error. Downstream cost tracking then records zero tokens, producing inaccurate cost estimates with no visible error signal to the caller or operator.Changes
features/tdd_langchain_token_count_silent_failure.feature— Behave feature file with a TDD issue-capture scenario tagged@tdd_issue,@tdd_issue_10395, and@tdd_expected_failfeatures/steps/tdd_langchain_token_count_silent_failure_steps.py— Step definitions for the new scenarioTDD Workflow
The scenario asserts that
_estimate_token_usage()propagates exceptions fromget_num_tokens()rather than silently returning0. This assertion fails against the current unfixed code (confirming the bug exists). The@tdd_expected_failtag inverts the result so CI reports the scenario as passed until the fix is merged.Once the corresponding bug fix PR (closing #10395) is merged, the
@tdd_expected_failtag must be removed from the feature file so the scenario runs normally as a regression guard.Closes #10395
This PR blocks issue #10395
Automated by CleverAgents Bot
Supervisor: Implementation | Agent: task-implementor
except Exception: return 0inLangChainChatProvider._count_tokens()causes inaccurate cost tracking #10395Review Summary — PR #10889
This is a TDD issue-capture test for bug #10395 (silent
except Exception: return 0inLangChainChatProvider._estimate_token_usage()). All CI checks are passing.1. CORRECTNESS — PASS
The test correctly targets the
except Exception: return 0block in_estimate_token_usage()(line ~287 oflangchain_chat_provider.py). A mock LLM raisesRuntimeErrorfromget_num_tokens(), and the test asserts the exception propagates rather than being silently swallowed.2. SPECIFICATION ALIGNMENT — PASS (minor note)
The test follows the TDD issue-capture workflow per CONTRIBUTING.md. The linked issue #10395 prescribed the feature file at
features/providers/test_langchain_token_counting.feature; the test is atfeatures/tdd_langchain_token_count_silent_failure.feature. This is a cosmetic deviation that does not affect test execution or discoverability.3. TEST QUALITY — PASS
@tdd_issue,@tdd_issue_10395,@tdd_expected_failon the scenario — all three tags present per CONTRIBUTING.md > TDD Issue Test Tags.AssertionErroronly (notValueError/RuntimeError) — compliant.@tdd_expected_failinverts the assertion failure.4. TYPE SAFETY — PASS
All functions have annotations (
context: Context,-> None), all context attributes typed (Exception | None,int | None). No# type: ignorecomments.5. READABILITY — PASS
_TOKEN_COUNT_ERROR_MESSAGEmakes test assertions descriptive.raised_exception,returned_token_count) are self-documenting.6. PERFORMANCE — N/A
Test file; no performance concerns.
7. SECURITY — PASS
No secrets, tokens, or unsafe patterns. All test doubles are local mocks.
8. CODE STYLE — PASS
Step definitions file is 115 lines (well under 500). Follows ruff conventions. Imports are top-level, uses
from __future__ import annotations.9. DOCUMENTATION — PASS
Module docstring is comprehensive. Every function has a docstring explaining its purpose and TDD context.
10. COMMIT AND PR QUALITY — PASS
test(providers): add failing scenario for silent token-count exception swallowing— correct Conventional Changelog format.tdd/m3-token-count-silent-failure— correct m3 milestone prefix.Closes #10395present.Verdict: APPROVED
All checklist categories pass. No blocking issues found. The test is a clean, well-documented TDD issue-capture that will serve as a regression guard once the fix PR for #10395 is merged and
@tdd_expected_failis removed.Non-blocking Suggestion
The file is placed at
features/tdd_langchain_token_count_silent_failure.featurewhile issue #10395 suggestedfeatures/providers/test_langchain_token_counting.feature. For consistency with the issue spec and easier correlation between issue and test file, consider relocating the feature file tofeatures/providers/in a future cleanup PR when the fix is merged.Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
Review Summary — PR #10889
This is a TDD issue-capture test for bug #10395 (silent
except Exception: return 0inLangChainChatProvider._estimate_token_usage()). All CI checks are passing.1. CORRECTNESS — PASS
The test correctly targets the
except Exception: return 0block in_estimate_token_usage()(line ~287 oflangchain_chat_provider.py). A mock LLM raisesRuntimeErrorfromget_num_tokens(), and the test asserts the exception propagates rather than being silently swallowed.2. SPECIFICATION ALIGNMENT — PASS (minor note)
The test follows the TDD issue-capture workflow per CONTRIBUTING.md. The linked issue #10395 prescribed the feature file at
features/providers/test_langchain_token_counting.feature; the test is atfeatures/tdd_langchain_token_count_silent_failure.feature. This is a cosmetic deviation that does not affect test execution or discoverability.3. TEST QUALITY — PASS
@tdd_issue,@tdd_issue_10395,@tdd_expected_failon the scenario — all three tags present per CONTRIBUTING.md > TDD Issue Test Tags.AssertionErroronly (notValueError/RuntimeError) — compliant.@tdd_expected_failinverts the assertion failure.4. TYPE SAFETY — PASS
All functions have annotations (
context: Context,-> None), all context attributes typed (Exception | None,int | None). No# type: ignorecomments.5. READABILITY — PASS
_TOKEN_COUNT_ERROR_MESSAGEmakes test assertions descriptive.raised_exception,returned_token_count) are self-documenting.6. PERFORMANCE — N/A
Test file; no performance concerns.
7. SECURITY — PASS
No secrets, tokens, or unsafe patterns. All test doubles are local mocks.
8. CODE STYLE — PASS
Step definitions file is 115 lines (well under 500). Follows ruff conventions. Imports are top-level, uses
from __future__ import annotations.9. DOCUMENTATION — PASS
Module docstring is comprehensive. Every function has a docstring explaining its purpose and TDD context.
10. COMMIT AND PR QUALITY — PASS
test(providers): add failing scenario for silent token-count exception swallowing— correct Conventional Changelog format.tdd/m3-token-count-silent-failure— correct m3 milestone prefix.Closes #10395present.Verdict: APPROVED
All checklist categories pass. No blocking issues found. The test is a clean, well-documented TDD issue-capture that will serve as a regression guard once the fix PR for #10395 is merged and
@tdd_expected_failis removed.Non-blocking Suggestion
The file is placed at
features/tdd_langchain_token_count_silent_failure.featurewhile issue #10395 suggestedfeatures/providers/test_langchain_token_counting.feature. For consistency with the issue spec and easier correlation between issue and test file, consider relocating the feature file tofeatures/providers/in a future cleanup PR when the fix is merged.Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
097b8c16ada4aeea3e7c