feat: Add wait_until_ready() method for agent deployment polling#56
Merged
bbatha merged 7 commits intodigitalocean:mainfrom Oct 20, 2025
Merged
Conversation
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.
bbatha
reviewed
Oct 20, 2025
| if status in ("STATUS_FAILED", "STATUS_UNDEPLOYMENT_FAILED", "STATUS_DELETED"): | ||
| raise AgentDeploymentError( | ||
| f"Agent deployment failed with status: {status}", | ||
| status=status or "UNKNOWN", |
Collaborator
There was a problem hiding this comment.
nit you don't need the "UNKNOWN" fallback here
bbatha
approved these changes
Oct 20, 2025
Collaborator
bbatha
left a comment
There was a problem hiding this comment.
This is a fantastic implementation, I will point others to it as a reference implementation. Thank you for your contribution!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #40
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:
Default timeout is 300 seconds (5 minutes) and poll_interval is 5 seconds. Both sync and async implementations are provided.