-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(ai): raise task error/warning history cap from 50 to a named constant (#1414) #1568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |||||||||||
|
|
||||||||||||
| import pytest | ||||||||||||
|
|
||||||||||||
| from ai.constants import CONST_STATUS_HISTORY_LIMIT | ||||||||||||
| from ai.modules.task.task_engine import Task | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
@@ -470,24 +471,24 @@ def test_update_status_error_event_appends_to_errors(): | |||||||||||
| assert t._status.errors == ['disk full'] | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| def test_update_status_errors_buffer_trims_to_50(): | ||||||||||||
| """Error buffer keeps only the most recent 50 entries.""" | ||||||||||||
| def test_update_status_errors_buffer_trims_to_limit(): | ||||||||||||
| """Error buffer keeps only the most recent CONST_STATUS_HISTORY_LIMIT entries.""" | ||||||||||||
| t = _task(status=_make_status_for_update()) | ||||||||||||
| t._status.errors = [f'err-{i}' for i in range(50)] | ||||||||||||
| t._status.errors = [f'err-{i}' for i in range(CONST_STATUS_HISTORY_LIMIT)] | ||||||||||||
| Task._update_status( | ||||||||||||
| t, | ||||||||||||
| { | ||||||||||||
| 'event': 'apaevt_status_error', | ||||||||||||
| 'body': {'message': 'err-new'}, | ||||||||||||
| }, | ||||||||||||
| ) | ||||||||||||
| assert len(t._status.errors) == 50 | ||||||||||||
| assert len(t._status.errors) == CONST_STATUS_HISTORY_LIMIT | ||||||||||||
| assert t._status.errors[-1] == 'err-new' | ||||||||||||
| assert 'err-0' not in t._status.errors # oldest evicted | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| def test_update_status_warning_event_appends_and_trims(): | ||||||||||||
| """An ``apaevt_status_warning`` event appends to warnings with the same 50-cap.""" | ||||||||||||
| """An ``apaevt_status_warning`` event appends to warnings with the same history cap.""" | ||||||||||||
|
Comment on lines
490
to
+491
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win Align the test name and docstring with its implementation, or add trimming assertions. The test is named Consider renaming the test to match the error tests (e.g., ♻️ Proposed refactor-def test_update_status_warning_event_appends_and_trims():
- """An ``apaevt_status_warning`` event appends to warnings with the same history cap."""
+def test_update_status_warning_event_appends_to_warnings():
+ """An ``apaevt_status_warning`` event appends to ``status.warnings``."""To fully cover the trimming behavior for warnings, you can add this new test alongside it: def test_update_status_warnings_buffer_trims_to_limit():
"""Warning buffer keeps only the most recent CONST_STATUS_HISTORY_LIMIT entries."""
t = _task(status=_make_status_for_update())
t._status.warnings = [f'warn-{i}' for i in range(CONST_STATUS_HISTORY_LIMIT)]
Task._update_status(
t,
{
'event': 'apaevt_status_warning',
'body': {'message': 'warn-new'},
},
)
assert len(t._status.warnings) == CONST_STATUS_HISTORY_LIMIT
assert t._status.warnings[-1] == 'warn-new'
assert 'warn-0' not in t._status.warnings # oldest evicted📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| t = _task(status=_make_status_for_update()) | ||||||||||||
| Task._update_status( | ||||||||||||
| t, | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Update the status-history tests for the new limit.
The existing error-buffer test still initializes 50 entries and asserts a final length of 50. With this implementation, it will contain 51 entries, so the test suite will fail. Update the test to use
CONST_STATUS_HISTORY_LIMITand seedlimitentries before appending the new message.🤖 Prompt for AI Agents