Skip to content

fix(bocha): accept validated date freshness filters - #352

Merged
Eigenwise merged 3 commits into
Eigenwise:mainfrom
linyuchao123:fix/bocha-date-filters
Nov 17, 2026
Merged

Eigenwise merged 3 commits into
Eigenwise:mainfrom
linyuchao123:fix/bocha-date-filters

Conversation

@linyuchao123

Copy link
Copy Markdown

The BoCha configuration treats YYYY-MM-DD and YYYY-MM-DD..YYYY-MM-DD as literal enum values. As a result, real date filters fail validation while the format placeholders are accepted.

Accept the existing time presets plus validated ISO calendar dates and ordered date ranges. Preserve valid filters unchanged in request payloads, reject invalid dates and placeholders, and document accepted values. The mocked configuration test now uses a dummy key instead of depending on BOCHA_API_KEY.

Validation:

  • Tests before the fix: 9 failed, 22 passed (including the existing missing-key test failure).
  • BoCha tests after the fix: 31 passed, with mocked HTTP calls.
  • Black, Flake8, and git diff --check passed for the changed files.

No live BoCha requests or real API keys were used.

@Eigenwise Eigenwise left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Confirmed: on main the Literal accepts the placeholder "YYYY-MM-DD" strings and rejects real dates. The validator fixes that. Small cleanup:

  • Move the new tests above the if __name__ == "__main__": block. They currently come after it.
  • Import ValidationError at the top of the test file instead of inside the test.
  • exc to error in the validator.

I couldn't check this against the live BoCha API (no key here). If you've verified that a same-day range like 2026-11-07..2026-11-07 is accepted, a note in the description would help.

Kenny Vaneetvelde and others added 2 commits November 17, 2026 14:59
The freshness tests sat after the __main__ guard; they now come before it.
ValidationError is imported at the top of the test file, and the validator's
caught exception is named error. Also merges main.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@Eigenwise Eigenwise left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for this, the validator is the right fix and I'm merging it.

Since you hadn't had a chance to get back to it, I pushed one commit to your branch with the three cleanups from my last review: the freshness tests now sit above the __main__ guard, ValidationError is imported at the top of the test file, and the caught exception is named error. I also merged main in.

Checked on current main with your branch merged: the tool's 38 tests pass, and 8 of them fail on main's source.

It also fixes an older test along the way: test_bocha_search_tool_config_params_real_case_cn read its key from BOCHA_API_KEY even though it runs against a mocked session, so it failed on any machine without that variable. With your fixed fake key it passes everywhere.

One thing is still unverified: the validator accepts a same-day range such as 2026-11-07..2026-11-07, and I couldn't check that against the live BoCha API because I don't have a working key here. If you know how the API treats it, a comment here would be useful.

@Eigenwise
Eigenwise merged commit 107a1ac into Eigenwise:main Nov 17, 2026
3 checks passed
Eigenwise added a commit that referenced this pull request Nov 17, 2026
Covers what #348, #490, #341, #352 and #353 changed in documented behavior:
one schema resolver shared by agents, tools, resources and prompts; nested
schema classes in saved history; the scraper's streamed download cap; the
YouTube tool's timestamp offset and client cleanup; the PDF reader's
extraction_mode and include_links; BoCha freshness validation; datetime
shifts by calendar days and elapsed time; the weather country filter; and
that a persistent history backend should override delete_turn_id.

Each statement was checked against the merged code on main.

Co-authored-by: Kenny Vaneetvelde <kenny@eigenwise.io>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants