-
Notifications
You must be signed in to change notification settings - Fork 7
WIP: Initial support of Tasks and Dataframes #73
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
Draft
3dgiordano
wants to merge
5
commits into
SEARCH_ACTIONS
Choose a base branch
from
TASKS_AND_DATAFRAMES
base: SEARCH_ACTIONS
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
78fc95e
Initial support of Tasks and Dataframes
3dgiordano 289207f
Use simple id for dataframes
3dgiordano 32e2f4d
Improve dataframe sql help with more hints
3dgiordano cb60529
Improve dataframe sql help with more hints
3dgiordano b0850ab
Improve dataframe sql help with more hints
3dgiordano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import asyncio | ||
|
|
||
| import pytest | ||
|
|
||
| import tools.async_task_manager as task_manager | ||
| from models.result import BaseResult | ||
|
|
||
|
|
||
| def _clear_tasks(): | ||
| task_manager._tasks.clear() | ||
|
|
||
|
|
||
| def test_submit_task_uses_crockford_base32_id(): | ||
| _clear_tasks() | ||
|
|
||
| async def scenario(): | ||
| async def action(): | ||
| return BaseResult(result=[{"ok": True}]) | ||
|
|
||
| task_id = task_manager.submit_task( | ||
| action={"manager": "TestManager", "method": "read"}, | ||
| coro_factory=action, | ||
| ) | ||
| record = task_manager.get_task_record(task_id) | ||
| assert record is not None | ||
| assert len(task_id) == 8 | ||
| assert all(ch in task_manager.TASK_ID_ALPHABET for ch in task_id) | ||
|
|
||
| while True: | ||
| record = task_manager.get_task_record(task_id) | ||
| if record and record.status in {"completed", "failed", "cancelled"}: | ||
| break | ||
| await asyncio.sleep(0.01) | ||
|
|
||
| assert task_manager.remove_task(task_id) is True | ||
|
|
||
| asyncio.run(scenario()) | ||
|
|
||
|
|
||
| def test_collision_policy_fails_after_ten_attempts(monkeypatch): | ||
| _clear_tasks() | ||
| task_manager._tasks["deadbeef"] = task_manager.TaskRecord( | ||
| task_id="deadbeef", | ||
| action={"manager": "TestManager", "method": "read"}, | ||
| created_at=0.0, | ||
| last_updated_at=0.0, | ||
| time_to_live_ms=None, | ||
| status=task_manager.STATUS_PARKING, | ||
| status_message="seed", | ||
| status_info="seed", | ||
| ) | ||
|
|
||
| monkeypatch.setattr(task_manager, "_generate_task_id", lambda: "deadbeef") | ||
|
|
||
| with pytest.raises(RuntimeError, match="Unable to allocate unique 8-char task id after 10 attempts."): | ||
| task_manager._allocate_task_id() | ||
|
|
||
|
|
||
| def test_task_lookup_is_case_insensitive(): | ||
| _clear_tasks() | ||
| now = 0.0 | ||
| task_manager._tasks["7k2p9m4q"] = task_manager.TaskRecord( | ||
| task_id="7k2p9m4q", | ||
| action={"manager": "ExecutionManager", "method": "list"}, | ||
| created_at=now, | ||
| last_updated_at=now, | ||
| time_to_live_ms=None, | ||
| status=task_manager.STATUS_WORKING, | ||
| status_message="running", | ||
| status_info="running", | ||
| ) | ||
|
|
||
| assert task_manager.get_task_record("7K2P9M4Q") is not None | ||
| assert task_manager.remove_task("7K2P9M4Q") is True | ||
| assert task_manager.get_task_record("7k2p9m4q") is None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Was this happening for a specific client? it would be good to know and keep track, good fix!
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.
This is an error caused by the client or the AI's misinterpretation of the specification's arguments.
The most common behavior is that the client performs an incorrect action, resulting in a Pydantic error because it doesn't comply with the specified interface. The AI recognizes the error and attempts the action again, the next time correctly.
This commonly occurs with models that have low precision in function calls or in some clients like VS Code (we don't know if it's AI or client or both).
This approach allows us to disable the Pydantic error and allow raw data to be sent. It is then processed more defensively by our logic, accepting both correct and incorrect formatting, attempting to resolve the data regardless of the AI's errors.
This minimizes the number of round trips the AI makes when it fails to correctly declare the tool call.
We doo some tricks to generate the arguments arg and also use normalize_action_args in utils to fix some of the patterns (in that function explain more about the supported format patterns).