Skip to content

Conversation

@cipheraxat
Copy link
Contributor

Resolves #40

  • Add wait_until_ready() method to AgentsResource and AsyncAgentsResource
  • Add AgentDeploymentError and AgentDeploymentTimeoutError exceptions
  • Add comprehensive test coverage for sync and async variants
  • Add example usage documentation

Users can now call client.agents.wait_until_ready(agent_id) instead of writing custom polling loops to wait for agent deployment completion.

The method polls the agent status every 5 seconds (configurable) until:

  • SUCCESS: Agent reaches STATUS_RUNNING (returns AgentRetrieveResponse)
  • FAILURE: Agent reaches STATUS_FAILED/STATUS_UNDEPLOYMENT_FAILED/STATUS_DELETED (raises AgentDeploymentError)
  • TIMEOUT: Agent doesn't reach STATUS_RUNNING within timeout period (raises AgentDeploymentTimeoutError)

Default timeout is 300 seconds (5 minutes) and poll_interval is 5 seconds. Both sync and async implementations are provided.

Resolves digitalocean#40

- Add wait_until_ready() method to AgentsResource and AsyncAgentsResource
- Add AgentDeploymentError and AgentDeploymentTimeoutError exceptions
- Add comprehensive test coverage for sync and async variants
- Add example usage documentation

Users can now call client.agents.wait_until_ready(agent_id) instead of
writing custom polling loops to wait for agent deployment completion.

The method polls the agent status every 5 seconds (configurable) until:
- SUCCESS: Agent reaches STATUS_RUNNING (returns AgentRetrieveResponse)
- FAILURE: Agent reaches STATUS_FAILED/STATUS_UNDEPLOYMENT_FAILED/STATUS_DELETED (raises AgentDeploymentError)
- TIMEOUT: Agent doesn't reach STATUS_RUNNING within timeout period (raises AgentDeploymentTimeoutError)

Default timeout is 300 seconds (5 minutes) and poll_interval is 5 seconds.
Both sync and async implementations are provided.
if status in ("STATUS_FAILED", "STATUS_UNDEPLOYMENT_FAILED", "STATUS_DELETED"):
raise AgentDeploymentError(
f"Agent deployment failed with status: {status}",
status=status or "UNKNOWN",
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit you don't need the "UNKNOWN" fallback here

Copy link
Collaborator

@bbatha bbatha left a comment

Choose a reason for hiding this comment

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

This is a fantastic implementation, I will point others to it as a reference implementation. Thank you for your contribution!

@bbatha bbatha merged commit dcef3d5 into digitalocean:main Oct 20, 2025
7 checks passed
@stainless-app stainless-app bot mentioned this pull request Oct 20, 2025
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.

Create a helper function to poll for agent deployment readiness

2 participants