Skip to content

Conversation

gayatrik-dev
Copy link

@gayatrik-dev gayatrik-dev commented Sep 25, 2025

This PR addresses #1966.

Features Implemented

The tool provides complete CRUD support via the following actions:

  • todo_create: Add a new todo item with optional description, due date, and metadata.
  • todo_get: Retrieve a specific todo by its unique todo_id.
  • todo_list: List all todos created by a specific user-tool pair.
  • todo_update: Update title, description, status, due date, or metadata of an existing todo.
  • todo_delete: Remove a specific todo by todo_id.

Technical Highlights

  • Todos are uniquely identified using UUID-based todo_ids.
  • MongoDB-backed with appropriate indexes on todo_id, user_id, and tool_id to ensure efficient queries.
  • Tool configuration supports an optional tool_id for contextual separation; defaults to default_{user_id} if none provided.

Tests

  • Added a comprehensive suite of unit tests using a fake in-memory MongoDB collection:
  • Covers creation, retrieval, listing, updating, deletion, and isolation across tool_ids and users.

Copy link

vercel bot commented Sep 25, 2025

@gayatrik-dev is attempting to deploy a commit to the Arc53 Team on Vercel.

A member of the Team first needs to authorize it.

@dartpain
Copy link
Contributor

Thank you for your PR,

I have 2 comments:

  1. user_id should come from decoded_token, "sub" property, this ensures safety.
  2. I like the actions and their params, but to make it more LLM friendly I think we should avoid using Timestamp and use simple date format precise to a second.

Copy link

vercel bot commented Sep 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
oss-docsgpt Ready Ready Preview Comment Oct 7, 2025 4:30pm

Copy link

codecov bot commented Sep 30, 2025

Codecov Report

❌ Patch coverage is 88.34951% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.07%. Comparing base (498e2b7) to head (68c42e7).
⚠️ Report is 77 commits behind head on main.

Files with missing lines Patch % Lines
application/agents/tools/todo_list.py 90.09% 10 Missing ⚠️
application/agents/tools/tool_manager.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1977      +/-   ##
==========================================
+ Coverage   34.67%   36.07%   +1.40%     
==========================================
  Files         131      136       +5     
  Lines        8703     9352     +649     
==========================================
+ Hits         3018     3374     +356     
- Misses       5685     5978     +293     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dartpain dartpain mentioned this pull request Oct 6, 2025
1 task
@gayatrik-dev
Copy link
Author

@dartpain, addressed the comments as suggested.

@dartpain
Copy link
Contributor

dartpain commented Oct 6, 2025

Hey @gayatrik-dev there seem to be some conflicts with the main branch.

Check out https://github.com/arc53/DocsGPT/blob/main/application/agents/tools/memory.py
and https://github.com/arc53/DocsGPT/blob/main/application/agents/tools/notes.py
To see how we create a unique one for each tool itself not only user via tool_id

@dartpain
Copy link
Contributor

dartpain commented Oct 7, 2025

Todo_id should correspond to a tool _id in the user_tools collection.

todo_id = str(uuid.uuid4())

Please check out https://github.com/arc53/DocsGPT/blob/main/application/agents/tools/memory.py
and https://github.com/arc53/DocsGPT/blob/main/application/agents/tools/notes.py

They handle it well there.

On tools init you should get tool_config param:
and use it to store tool_id

if tool_config and "tool_id" in tool_config:
            self.tool_id = tool_config["tool_id"]

Then when you make db queries reference:
self.tool_id

@gayatrik-dev
Copy link
Author

hi, as i understand you want one todo per user_id and tool_id?

@dartpain
Copy link
Contributor

dartpain commented Oct 7, 2025

Such that if one user creates multiple todo tools - they are isolated.

@gayatrik-dev
Copy link
Author

@dartpain , please review the updated changes.

@dartpain
Copy link
Contributor

dartpain commented Oct 7, 2025

Few issues

The tool needs a real per-todo identifier (e.g., generate a todo_id super simple one can be interger, can store it in the same mongodb document)

application/agents/tools/todo_list.py:130 documents “Get a single todo by id”, but _get_todo, _update_todo, and _delete_todo (lines 86-109) dont accept a todo id. Just make an action that fetches all todos.

application/agents/tools/todo_list.py:88 returns the raw Mongo document, which still contains _id and datetime fields. These values are not JSON-serializable clean it up a bit.

Thank you!

@gayatrik-dev
Copy link
Author

Hi, I hope this addresses your concerns — the refactor supports either many todos within a single tool or multiple tools each with their own todos for a given user.

@dartpain
Copy link
Contributor

dartpain commented Oct 7, 2025

Great, I noticed tool_id is from uuid, I think it makes LLM's life harder to type it all out.
What if we just use simple interger index, like 1,2,3,4...
Just fetch top number from db collection and set new tasks id as n+1

@gayatrik-dev
Copy link
Author

How about we introduce a counters collection in MongoDB to track the current sequence number?
Then for each new todo, we use find_one_and_update with $inc to atomically generate the next todo_id.

@gayatrik-dev
Copy link
Author

       result = self._db.counters.find_one_and_update(
            {"_id": "todo_id"},
            {"$inc": {"seq": 1}},
            upsert=True,
            return_document=True
        )
        return result["seq"]

and then in create_todo -> todo_id = self._get_next_todo_id()

  • this should take care of any parallel requests/ concurrency issues

@dartpain
Copy link
Contributor

dartpain commented Oct 8, 2025

I would suggest against adding another collection / table. Todo lists are going to be relatively small (up to 5 items on average), thus I advise we take a simplest possible approach, just track index within the same mongodb document.

@gayatrik-dev
Copy link
Author

hi, is everything okay from your end for the changes made?

@dartpain
Copy link
Contributor

dartpain commented Oct 9, 2025

Does it seem to be working well for you, im getting this error on my end to end test:
CleanShot 2025-10-09 at 14 38 51@2x

@gayatrik-dev
Copy link
Author

Hi, i did manual testing and it works fine for me. Please find logs

$ docker exec -it e6e609767782 mongosh
Current Mongosh Log ID: 68e7f725d61484df45ce5f46
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.5.8
Using MongoDB:          6.0.26
Using Mongosh:          2.5.8

For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/


To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.

------
   The server generated these startup warnings when booting
   2025-10-09T15:15:30.915+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
   2025-10-09T15:15:31.237+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
   2025-10-09T15:15:31.237+00:00: vm.max_map_count is too low
------

test> use docsgpt
switched to db docsgpt
docsgpt> db.todos.find().pretty()
[
  {
    _id: ObjectId('68e7f7882f6b7dda7f5a02e0'),
    todo_id: 1,
    user_id: 'user_1',
    tool_id: 'tool_todo',
    title: 'Test_Sample',
    description: 'Testing real db',
    status: 'done',
    metadata: {},
    due_date: null,
    created_at: ISODate('2025-10-09T17:57:28.245Z'),
    updated_at: ISODate('2025-10-09T17:57:28.253Z')
  }
]

@gayatrik-dev
Copy link
Author

fixed few issues with test-cases also after making "todo_id" changes. let me know if you have further comments. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

application Application tests Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants