Skip to content

fix(quick-router): route "how much is" arithmetic to the calculator - #871

Merged
matedev01 merged 2 commits into
GeniePod:mainfrom
Yurii214:fix/how-much-is-arithmetic
Jul 29, 2026
Merged

fix(quick-router): route "how much is" arithmetic to the calculator#871
matedev01 merged 2 commits into
GeniePod:mainfrom
Yurii214:fix/how-much-is-arithmetic

Conversation

@Yurii214

@Yurii214 Yurii214 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

arithmetic_expression strips the calculate / what is lead-ins before the all-math-chars gate, but not how much is — so arithmetic behind that lead-in keeps its question words, fails the gate, and falls through to the LLM. This is inconsistent: how much is 20% of 50 already routes today, because percentage_expression runs first and strips no lead-in.

utterance on main expected
how much is 45 times 6 ABSTAIN calculate{45 * 6}
how much is 100 divided by 4 ABSTAIN calculate{100 / 4}
how much is 2 plus 2 ABSTAIN calculate{2 + 2}

The what is / calculate forms already resolve today.

Changes

  • Add how much is to the lead-in strip chain in arithmetic_expression, mirroring the existing what is / calculate entries.
  • Negatives are unchanged: the two post-strip gates still require a digit AND an operator char AND all-math-chars, so how much is a ticket (no digit) and how much is 5 dollars in euros (no operator) still abstain; how much is 20% of 50 stays on the earlier percentage path.
  • Add routes_how_much_is_arithmetic_to_calculate (three phrasings: times / divided by / plus).

Real Behavior Proof

  • I have built and run the affected code locally (or noted why I could not).
  • I have verified the change end-to-end on Jetson hardware.
  • I have NOT verified on Jetson hardware, and I explain the equivalent verification path or validation gap below.

Tested profile / hardware (check all that apply):

  • jetson
  • raspberry_pi
  • portable_sbc
  • laptop
  • mac
  • CI-only / docs-only
  • Not run locally

Ran cargo test -p genie-core --no-default-features --lib tools::quick (108 passed) and --test calc_input_test (13 passed); the new routes_how_much_is_arithmetic_to_calculate test fails on main (all three utterances route to None → panic) and passes with the change. cargo clippy and cargo fmt --check are clean. The change is pure text-classification logic with no hardware dependency, so the laptop run exercises the full affected path.

Summary by CodeRabbit

  • Bug Fixes

    • Improved routing for natural-language arithmetic requests that start with “how much is …”.
    • Such utterances now correctly route to the calculator tool and handle multiplication, division, and addition as expected.
  • Tests

    • Added a regression test to verify “how much is …” arithmetic produces the correct calculator tool calls.

The arithmetic lead-in strip set accepted "what is"/"calculate" but not
"how much is", so "how much is 45 times 6" kept its question words, failed
the all-math-chars gate, and fell through to the LLM — even though "how much
is 20% of 50" already routes (percentage_expression strips no lead-in). Add
the lead-in so arithmetic behind it routes to calculate like the others.
@github-actions github-actions Bot added the bug Something isn't working label Jul 28, 2026
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 610806ff-f9d0-4e02-b73a-42fd86c805c8

📥 Commits

Reviewing files that changed from the base of the PR and between 4f3a38c and 96535d1.

📒 Files selected for processing (1)
  • crates/genie-core/src/tools/quick.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/genie-core/src/tools/quick.rs

📝 Walkthrough

Walkthrough

The arithmetic router recognizes "how much is " prompts and sends them to the deterministic calculator path. Regression coverage verifies multiplication, division, and addition expressions.

Changes

Arithmetic routing

Layer / File(s) Summary
Prefix routing and regression coverage
crates/genie-core/src/tools/quick.rs
The arithmetic parser accepts the "how much is " prefix, and tests verify calculate tool calls with digitized expressions.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: matedev01

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: routing “how much is” arithmetic to the calculator.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@matedev01 matedev01 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — arithmetic_expression stripped 'calculate '/'what is ' lead-ins but not 'how much is', so that phrasing kept its question words and failed the all-math-chars gate. Verified: clippy -D warnings clean, calc/quick-router tests (130) pass, fmt clean, live BFCL strict_accuracy 96.15% (no regression).

@matedev01
matedev01 merged commit 684e022 into GeniePod:main Jul 29, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants