Skip to content

feat: autonomous error tracking and memory management#932

Merged
hyacinthus merged 4 commits intomainfrom
hyacinthus
Jan 5, 2026
Merged

feat: autonomous error tracking and memory management#932
hyacinthus merged 4 commits intomainfrom
hyacinthus

Conversation

@hyacinthus
Copy link
Collaborator

This PR adds error activity tracking for autonomous task execution and memory management improvements.

Changes:

  • Add error activity tracking for autonomous task execution with detailed error messages
  • Add has_memory flag support for autonomous tasks
  • Fix changelog generation bug

These enhancements improve error visibility and task execution reliability in autonomous mode.

Copilot AI review requested due to automatic review settings January 5, 2026 01:30
@hyacinthus hyacinthus merged commit 153936e into main Jan 5, 2026
5 checks passed
@hyacinthus hyacinthus deleted the hyacinthus branch January 5, 2026 01:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_memory flag 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)
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

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)

Copilot uses AI. Check for mistakes.
elif last_msg.author_type == AuthorType.SYSTEM:
error_text = f"Task execution error: {last_msg.message}"
else:
error_text = "Unexpected return error"
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

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}"

Suggested change
error_text = "Unexpected return error"
error_text = f"Unexpected author type in response: {last_msg.author_type}"

Copilot uses AI. Check for mistakes.
# Clear thread memory if has_memory is False
if not has_memory:
try:
_ = await clear_thread_memory(agent_id, chat_id)
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

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)

Suggested change
_ = await clear_thread_memory(agent_id, chat_id)
await clear_thread_memory(agent_id, chat_id)

Copilot uses AI. Check for mistakes.
agent_id=agent_id,
text="Unexpected result: empty response",
)
_ = await create_agent_activity(activity)
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

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)

Copilot uses AI. Check for mistakes.
agent_id=agent_id,
text=f"Autonomous task exception: {str(e)}",
)
_ = await create_agent_activity(activity)
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

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)

Copilot uses AI. Check for mistakes.
Comment on lines +85 to +89
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:
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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:

Copilot uses AI. Check for mistakes.
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.

1 participant