Skip to content

feat: Add date and time awareness tool (#20)#49

Closed
AlyanPremani05 wants to merge 8 commits into
Finntegrate:mainfrom
AlyanPremani05:add-datetime-tool
Closed

feat: Add date and time awareness tool (#20)#49
AlyanPremani05 wants to merge 8 commits into
Finntegrate:mainfrom
AlyanPremani05:add-datetime-tool

Conversation

@AlyanPremani05

@AlyanPremani05 AlyanPremani05 commented Jun 27, 2026

Copy link
Copy Markdown

Closes #20

Summary

Adds a get_current_datetime() tool that returns the current date and time
in Helsinki (Finnish) local time, as a langchain_core @tool-decorated
function.

  • tapio/tools/datetime_tool.pyget_current_datetime() tool, returns a
    human-readable Helsinki local time string (e.g. "Tuesday, 27 June 2026,
    14:32 EEST")
  • tapio/tools/__init__.py — exports ALL_TOOLS list containing the new tool
  • tests/tools/test_datetime_tool.py — tests that the tool returns a string
    and includes a timezone abbreviation (EET/EEST)

Summary by CodeRabbit

  • New Features
    • Added a date/time utility that returns the current time formatted for the Helsinki timezone.
    • Exposed the utility via the package’s exported tools list.
  • Bug Fixes
    • Improved reliability by falling back to UTC when Helsinki timezone data isn’t available.
  • Tests
    • Added coverage to ensure the utility returns a non-empty string when timezone data is missing.
    • Expanded assertions to verify Helsinki timezone/DST indicators are present when available.
  • Chores
    • Added a pinned tzdata runtime dependency.

@coderabbitai

coderabbitai Bot commented Jun 27, 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: 4ecb9079-7b8e-4932-b80f-45895f0a7f14

📥 Commits

Reviewing files that changed from the base of the PR and between c0da398 and 74cfa93.

📒 Files selected for processing (3)
  • tapio/tools/__init__.py
  • tapio/tools/datetime_tool.py
  • tests/tools/test_datetime_tool.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • tapio/tools/init.py
  • tests/tools/test_datetime_tool.py
  • tapio/tools/datetime_tool.py

📝 Walkthrough

Walkthrough

Adds a new get_current_datetime LangChain tool that returns the current time in Helsinki format, exports it from tapio.tools, adds tzdata, and extends tests for the normal and fallback timezone paths.

Helsinki Datetime Tool

Layer / File(s) Summary
Tool implementation and export
tapio/tools/datetime_tool.py, tapio/tools/__init__.py, pyproject.toml
get_current_datetime() formats the current UTC time in Helsinki, falls back to UTC when ZoneInfo is unavailable, is exported through ALL_TOOLS and __all__, and adds tzdata to runtime dependencies.
Datetime tool tests
tests/tools/test_datetime_tool.py
Tests cover non-empty output, Helsinki timezone abbreviations, and the fallback path when ZoneInfo raises ZoneInfoNotFoundError.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A bunny checks the clock with glee,
Helsinki time for all to see,
If zones go missing, still it runs,
A tiny tool for morning buns 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the addition of a date and time awareness tool and matches the main change set.
Linked Issues check ✅ Passed The PR implements get_current_datetime() and registers it in the tool registry, matching issue #20's checklist.
Out of Scope Changes check ✅ Passed The added tzdata dependency supports the new timezone-aware tool and does not appear unrelated to the issue scope.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
tests/tools/test_datetime_tool.py (2)

4-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add return annotations and docstrings to the new tests.

Both test functions are new Python functions, but they currently omit -> None and the required docstrings. As per coding guidelines, "Use type hints for all Python function parameters and return types." and "Use Google-style docstrings for all Python functions and classes."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/tools/test_datetime_tool.py` around lines 4 - 13, Add missing return
annotations and docstrings to the new test functions in the datetime tool tests.
Update test_returns_string and test_includes_timezone to explicitly return None
and include concise Google-style docstrings that describe what each test
verifies. Keep the existing assertions unchanged and ensure the function
signatures in test_datetime_tool.py follow the project’s typing and
documentation guidelines.

Source: Coding guidelines


4-13: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Make these assertions deterministic.

These checks would still pass if the tool returned the wrong Helsinki clock time but kept an EET/EEST suffix. Please freeze a known UTC instant and assert the exact rendered string for at least one winter and one summer case.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/tools/test_datetime_tool.py` around lines 4 - 13, The datetime tool
tests are nondeterministic because they only check type, length, and timezone
suffix, so they can pass even with the wrong clock time. Update the tests in
test_returns_string and test_includes_timezone to freeze a fixed UTC instant and
assert the exact rendered Helsinki datetime string for one winter case and one
summer case. Use get_current_datetime.invoke as the target under test and keep
the assertions fully exact instead of checking only for EET/EEST.
tapio/tools/datetime_tool.py (1)

11-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Normalize the new function docstring to the repo’s Python standard.

get_current_datetime has the return annotation already, but the new Python guideline also requires the repository’s docstring format and sections for functions. As per coding guidelines, "Use type hints for all Python function parameters and return types." and "Use Google-style docstrings for all Python functions and classes."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tapio/tools/datetime_tool.py` around lines 11 - 21, The new
get_current_datetime function docstring is not in the repository’s required
Python style. Update its documentation to match the project’s Google-style
function docstrings used elsewhere in tapio/tools, keeping the existing return
annotation and adding the standard function docstring sections/wording expected
by the repo. Ensure the final docstring is consistent with the Python guidelines
for get_current_datetime and similar functions.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tapio/tools/datetime_tool.py`:
- Around line 10-23: The datetime tool contract does not match the requested
API: `get_current_datetime()` returns a human-readable timestamp, but the issue
expects `get_current_date()` with an ISO-formatted date plus weekday. Update the
tool in `datetime_tool.py` to expose the correct function name and return a
machine-friendly date string suitable for comparisons and deadline logic, while
keeping the Helsinki timezone behavior in the date computation.
- Line 7: Avoid resolving HELSINKI_TZ at import time in datetime_tool.py, since
ZoneInfo("Europe/Helsinki") can fail before ALL_TOOLS is built in minimal
runtimes. Update the datetime_tool module to either add tzdata as a runtime
dependency or load the zone lazily with a safe fallback, and make sure any
initialization in the module-level constants or datetime tool setup does not
require ZoneInfo to succeed during import.

---

Nitpick comments:
In `@tapio/tools/datetime_tool.py`:
- Around line 11-21: The new get_current_datetime function docstring is not in
the repository’s required Python style. Update its documentation to match the
project’s Google-style function docstrings used elsewhere in tapio/tools,
keeping the existing return annotation and adding the standard function
docstring sections/wording expected by the repo. Ensure the final docstring is
consistent with the Python guidelines for get_current_datetime and similar
functions.

In `@tests/tools/test_datetime_tool.py`:
- Around line 4-13: Add missing return annotations and docstrings to the new
test functions in the datetime tool tests. Update test_returns_string and
test_includes_timezone to explicitly return None and include concise
Google-style docstrings that describe what each test verifies. Keep the existing
assertions unchanged and ensure the function signatures in test_datetime_tool.py
follow the project’s typing and documentation guidelines.
- Around line 4-13: The datetime tool tests are nondeterministic because they
only check type, length, and timezone suffix, so they can pass even with the
wrong clock time. Update the tests in test_returns_string and
test_includes_timezone to freeze a fixed UTC instant and assert the exact
rendered Helsinki datetime string for one winter case and one summer case. Use
get_current_datetime.invoke as the target under test and keep the assertions
fully exact instead of checking only for EET/EEST.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b53c3867-20ab-4b83-922d-5ed76727a446

📥 Commits

Reviewing files that changed from the base of the PR and between 23e7a04 and eb281fb.

📒 Files selected for processing (3)
  • tapio/tools/__init__.py
  • tapio/tools/datetime_tool.py
  • tests/tools/test_datetime_tool.py

Comment thread tapio/tools/datetime_tool.py Outdated
Comment thread tapio/tools/datetime_tool.py Outdated
@AlyanPremani05

Copy link
Copy Markdown
Author

Forgot to remove the TODO (That is the issue that Sonar Cloud is showing)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
tests/tools/test_datetime_tool.py (1)

19-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Annotate the new test signature and docstring.

test_when_tzdata_missing introduces an untyped monkeypatch parameter and a free-form docstring. Please add a parameter annotation, -> None, and convert the docstring to the required format. As per coding guidelines, **/*.py should use type hints for all function parameters/returns and documented Python docstrings.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/tools/test_datetime_tool.py` around lines 19 - 25, Update
test_when_tzdata_missing to follow the Python typing/docstring guidelines: add a
type annotation for the monkeypatch parameter, add an explicit -> None return
annotation, and rewrite the docstring into the required documented Python style
used in tests. Keep the change localized to this test function in
tests/tools/test_datetime_tool.py.

Source: Coding guidelines

tapio/tools/datetime_tool.py (1)

7-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Bring these function docstrings in line with the repo standard.

_get_helsinki_tz() is undocumented, and get_current_datetime() still uses a plain Returns: section instead of the required :return:-style docs. Please convert both docstrings to the project format so the tool contract is documented consistently. As per coding guidelines, **/*.py functions need Google-style docstrings with documented return values and exceptions.

Also applies to: 15-25

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tapio/tools/datetime_tool.py` around lines 7 - 11, The datetime tool
docstrings are not following the repo’s Python docstring standard. Update
`_get_helsinki_tz()` to add a Google-style docstring that documents its return
value and any fallback behavior, and update `get_current_datetime()` to replace
the plain `Returns:` section with the required `:return:`-style documentation.
Keep the formatting consistent with the project’s `**/*.py` docstring convention
and make sure both functions are documented clearly.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/tools/test_datetime_tool.py`:
- Around line 27-29: The current test only verifies that
get_current_datetime.invoke returns a non-empty string, so it does not cover the
UTC fallback contract. Update the test around get_current_datetime to assert
that the rendered datetime includes the UTC timezone when _get_helsinki_tz()
degrades, using the existing get_current_datetime symbol so the fallback
behavior is explicitly validated.

---

Nitpick comments:
In `@tapio/tools/datetime_tool.py`:
- Around line 7-11: The datetime tool docstrings are not following the repo’s
Python docstring standard. Update `_get_helsinki_tz()` to add a Google-style
docstring that documents its return value and any fallback behavior, and update
`get_current_datetime()` to replace the plain `Returns:` section with the
required `:return:`-style documentation. Keep the formatting consistent with the
project’s `**/*.py` docstring convention and make sure both functions are
documented clearly.

In `@tests/tools/test_datetime_tool.py`:
- Around line 19-25: Update test_when_tzdata_missing to follow the Python
typing/docstring guidelines: add a type annotation for the monkeypatch
parameter, add an explicit -> None return annotation, and rewrite the docstring
into the required documented Python style used in tests. Keep the change
localized to this test function in tests/tools/test_datetime_tool.py.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2396dbd8-00a9-442c-98bf-1d6e8e3952b8

📥 Commits

Reviewing files that changed from the base of the PR and between eb281fb and d4316f5.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • pyproject.toml
  • tapio/tools/datetime_tool.py
  • tests/tools/test_datetime_tool.py

Comment thread tests/tools/test_datetime_tool.py Outdated
@AlyanPremani05

Copy link
Copy Markdown
Author

@brylie
I am done with the fixes. Please have a look

@AlyanPremani05 AlyanPremani05 requested a review from brylie June 28, 2026 10:13
brylie added a commit that referenced this pull request Jun 28, 2026
set -o pipefail: the default shell is bash -e {0} with no pipefail, so
the | tee pipelines added for output capture were silently swallowing
prek/mypy/pyrefly/pytest's real exit code -- confirmed against PR #49's
actual run logs, which show "shell: /usr/bin/bash -e {0}". Without this
fix the lint job in particular would never fail again, undoing the
honest-status fix from the prior commit.

Randomize the GITHUB_OUTPUT heredoc delimiter: a fixed delimiter could
appear verbatim in captured tool output and prematurely close the
heredoc, letting the remaining (attacker-controlled, since it's PR file
content) lines be parsed as additional GITHUB_OUTPUT entries.
brylie added a commit that referenced this pull request Jun 28, 2026
* Make CI failures honest and actionable

The lint job's "Lint (prek)" check showed green even when prek itself
failed, because continue-on-error masked it from the job's own status
-- only the report job's gate caught it, with no indication of why.
Remove continue-on-error from the (single-step) lint job so it fails
visibly when prek does.

Also surface the actual failure output instead of just pass/fail:
mypy and pyrefly findings now get inline ::error annotations on the
Files changed tab, and prek/mypy/pyrefly/pytest output is captured
and included in the job summary and sticky PR comment, alongside the
local command to reproduce and fix each one.

* Improve Dockerfile comments for clarity on Yarn source removal and zstd installation

* Fix two real CI bugs in the new output-capture steps

set -o pipefail: the default shell is bash -e {0} with no pipefail, so
the | tee pipelines added for output capture were silently swallowing
prek/mypy/pyrefly/pytest's real exit code -- confirmed against PR #49's
actual run logs, which show "shell: /usr/bin/bash -e {0}". Without this
fix the lint job in particular would never fail again, undoing the
honest-status fix from the prior commit.

Randomize the GITHUB_OUTPUT heredoc delimiter: a fixed delimiter could
appear verbatim in captured tool output and prematurely close the
heredoc, letting the remaining (attacker-controlled, since it's PR file
content) lines be parsed as additional GITHUB_OUTPUT entries.
brylie added a commit that referenced this pull request Jun 28, 2026
The "report" job's PR comment step was failing silently (403 Resource
not accessible by integration) for every fork-originated PR, since
GITHUB_TOKEN is read-only for pull_request runs triggered by forks.
Confirmed against PR #49 (a fork PR): the comment body was built
correctly but the POST itself was rejected, and continue-on-error
hid the failure entirely -- no comment ever appeared.

Split the work in two: "report" now builds the comment body and
uploads it as an artifact instead of posting it directly, dropping
its pull-requests: write permission since it no longer needs it. A
new workflow, comment-on-pr.yml, triggers on workflow_run once CI
completes and posts/updates the comment from there -- workflow_run
always runs with the base repo's own permissions using this file as
committed on the default branch, regardless of which fork triggered
the original run, so it works for both fork and same-repo PRs without
granting fork code any elevated token access.
@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown

👋 Hi @AlyanPremani05, thanks for the pull request! Before this can be merged, please address: Lint (prek).

Details and local reproduction commands are below, with links to the relevant CONTRIBUTING.md section for each.

CI Failures

❌ prek
check yaml...............................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check json...............................................................Passed
check toml...............................................................Passed
check for merge conflicts................................................Passed
pyupgrade................................................................Passed
Add trailing commas......................................................Passed
ruff (legacy alias)......................................................Passed
ruff format..............................................................Failed
- hook id: ruff-format
- files were modified by this hook

  1 file reformatted, 53 files left unchanged
keep-sorted..............................................................Passed
Lint GitHub Actions workflows............................................Passed
Lint Markdown............................................................Passed

Run uv run prek run --all-files locally to reproduce and fix. See Pre-commit Hooks (prek) in CONTRIBUTING.md.

Test Coverage Report

87% coverage (required: ≥80%)

Coverage meets the project threshold. 🎉

@brylie

brylie commented Jun 28, 2026

Copy link
Copy Markdown
Member

Hei @AlyanPremani05. I've made some changes to CI in the main branch and updated your working branch with those change. Now, the CI failures are more helpful, including line-level feedback and a summary comment. Please pull the most recent changes into your local branch and then fix the lint issues, so we can merge this branch. Thanks!

@sonarqubecloud

Copy link
Copy Markdown

@AlyanPremani05

Copy link
Copy Markdown
Author

@brylie Pulled your latest CI changes and fixed the lint issues .This should be good to go I guess. let me know if anything else comes up.

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.

Date and time awareness tool

2 participants