feat: autonomous error tracking and memory management#932
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds error activity tracking for autonomous task execution and introduces memory management capabilities for autonomous tasks. The changes improve error visibility and provide control over conversation memory persistence between autonomous runs.
- Added
has_memoryflag support across autonomous task creation, editing, and execution to control thread memory persistence - Implemented comprehensive error tracking that creates agent activities for empty responses, system errors, and exceptions during autonomous task execution
- Fixed chronological ordering of dates in CHANGELOG.md for versions 0.8.38, 0.8.37, and 0.8.35
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| intentkit/skills/system/add_autonomous_task.py | Added has_memory parameter to allow configuring memory retention when creating autonomous tasks |
| intentkit/skills/system/edit_autonomous_task.py | Added has_memory parameter to support updating memory retention settings for existing tasks |
| intentkit/models/agent.py | Added has_memory field to the AgentAutonomous model with appropriate validation and defaults |
| intentkit/models/agent_schema.json | Updated JSON schema to include the has_memory boolean property with description and default value |
| app/entrypoints/autonomous.py | Implemented memory clearing logic and comprehensive error tracking with agent activity creation for various failure scenarios |
| app/autonomous.py | Updated task scheduling to pass has_memory parameter to the execution function with backward compatibility |
| CHANGELOG.md | Added v0.8.39 release notes and corrected date inconsistencies in previous version entries |
Comments suppressed due to low confidence (1)
intentkit/models/agent.py:775
- This import of module re is redundant, as it was previously imported on line 6.
import re
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| agent_id=agent_id, | ||
| text=error_text, | ||
| ) | ||
| _ = await create_agent_activity(activity) |
There was a problem hiding this comment.
The underscore assignment pattern is used here, but the return value from create_agent_activity is not used anywhere. While this is valid Python, it's more idiomatic to simply call the function without assignment when the return value is intentionally unused. Consider changing to: await create_agent_activity(activity)
| elif last_msg.author_type == AuthorType.SYSTEM: | ||
| error_text = f"Task execution error: {last_msg.message}" | ||
| else: | ||
| error_text = "Unexpected return error" |
There was a problem hiding this comment.
The error message "Unexpected return error" is vague and doesn't provide useful context about what went wrong. Consider including more details such as the actual author_type value that was encountered to help with debugging. For example: "Unexpected author type in response: {last_msg.author_type}"
| error_text = "Unexpected return error" | |
| error_text = f"Unexpected author type in response: {last_msg.author_type}" |
| # Clear thread memory if has_memory is False | ||
| if not has_memory: | ||
| try: | ||
| _ = await clear_thread_memory(agent_id, chat_id) |
There was a problem hiding this comment.
The underscore assignment pattern is used here, but the return value from clear_thread_memory is not used anywhere. While this is valid Python, it's more idiomatic to simply call the function without assignment when the return value is intentionally unused. Consider changing to: await clear_thread_memory(agent_id, chat_id)
| _ = await clear_thread_memory(agent_id, chat_id) | |
| await clear_thread_memory(agent_id, chat_id) |
| agent_id=agent_id, | ||
| text="Unexpected result: empty response", | ||
| ) | ||
| _ = await create_agent_activity(activity) |
There was a problem hiding this comment.
The underscore assignment pattern is used here, but the return value from create_agent_activity is not used anywhere. While this is valid Python, it's more idiomatic to simply call the function without assignment when the return value is intentionally unused. Consider changing to: await create_agent_activity(activity)
| agent_id=agent_id, | ||
| text=f"Autonomous task exception: {str(e)}", | ||
| ) | ||
| _ = await create_agent_activity(activity) |
There was a problem hiding this comment.
The underscore assignment pattern is used here, but the return value from create_agent_activity is not used anywhere. While this is valid Python, it's more idiomatic to simply call the function without assignment when the return value is intentionally unused. Consider changing to: await create_agent_activity(activity)
| if last_msg.author_type == AuthorType.AGENT: | ||
| pass # Success, do nothing | ||
| elif last_msg.author_type == AuthorType.SYSTEM: | ||
| error_text = f"Task execution error: {last_msg.message}" | ||
| else: |
There was a problem hiding this comment.
The pass statement with a comment is not very meaningful and could be removed. The if-elif-else structure would be clearer without this branch, or the comment could be more descriptive. Consider restructuring to only check for error conditions without the pass statement.
| if last_msg.author_type == AuthorType.AGENT: | |
| pass # Success, do nothing | |
| elif last_msg.author_type == AuthorType.SYSTEM: | |
| error_text = f"Task execution error: {last_msg.message}" | |
| else: | |
| if last_msg.author_type == AuthorType.SYSTEM: | |
| error_text = f"Task execution error: {last_msg.message}" | |
| elif last_msg.author_type != AuthorType.AGENT: |
This PR adds error activity tracking for autonomous task execution and memory management improvements.
Changes:
These enhancements improve error visibility and task execution reliability in autonomous mode.