FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: Add wait_until_ready() method for agent deployment polling by cipheraxat · Pull Request #56 · digitalocean/gradient-python · GitHub

This repository was archived by the owner on Aug 17, 2026. It is now read-only.

feat: Add wait_until_ready() method for agent deployment polling - #56

Merged
bbatha merged 7 commits into
digitalocean:mainfrom
cipheraxat:feat/agent-wait-until-ready
Oct 20, 2025
Merged

feat: Add wait_until_ready() method for agent deployment polling#56
bbatha merged 7 commits into
digitalocean:mainfrom
cipheraxat:feat/agent-wait-until-ready

Conversation

Copy link
Copy Markdown
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.
Comment thread src/gradient/resources/agents/agents.py Outdated
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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

bbatha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

bbatha merged commit dcef3d5 into digitalocean:main Oct 20, 2025
7 checks passed
stainless-app Bot mentioned this pull request Oct 20, 2025
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

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


Back | FazBrowse Home | New Git URL