Skip to content

[Python SDK] Create custom exception classes #111

@santoshkumarradha

Description

@santoshkumarradha

Summary

The Python SDK currently uses generic exceptions like RuntimeError and Exception. Creating domain-specific exception classes will improve error handling and debugging.

Current State

  • Location: sdk/python/agentfield/
  • Issue: Generic exceptions throughout the codebase
  • Current: Only RateLimitError exists as a custom exception

Proposed Exception Classes

Create the following exception hierarchy:

class AgentFieldError(Exception):
    """Base exception for all AgentField SDK errors."""
    pass

class AgentFieldClientError(AgentFieldError):
    """Error communicating with the AgentField control plane."""
    pass

class ExecutionTimeoutError(AgentFieldError):
    """Execution timed out waiting for completion."""
    pass

class MemoryAccessError(AgentFieldError):
    """Error accessing agent memory storage."""
    pass

class RegistrationError(AgentFieldError):
    """Error registering agent with control plane."""
    pass

class ValidationError(AgentFieldError):
    """Input validation error."""
    pass

Tasks

  1. Create sdk/python/agentfield/exceptions.py with exception classes
  2. Export exceptions from sdk/python/agentfield/__init__.py
  3. Update docstrings with raised exceptions information

Acceptance Criteria

  • Exception classes created in exceptions.py
  • Exceptions exported in package __init__.py
  • Each exception class has a clear docstring
  • Tests pass (pytest)
  • Linting passes (ruff check)

Files

  • sdk/python/agentfield/exceptions.py (new)
  • sdk/python/agentfield/__init__.py (update exports)

Using AI to solve this issue? Read our AI-Assisted Contributions guide for testing requirements, prompt strategies, and common pitfalls to avoid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersrefactorCode quality and refactoring improvementssdk:pythonPython SDK related

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions