Skip to content

Commit 7cf24ef

Browse files
Alex Holmbergclaude
authored andcommitted
fix(11.3-01): prevent agent from polling deployment status in infinite loop
The agent was calling get_deployment_status repeatedly without waiting, creating an infinite polling loop. Updated the tool to: 1. Add explicit "action" field in response: - STOP_POLLING: deployment done (success/failure) - INFORM_USER_AND_WAIT: tell user to wait, let them ask for updates 2. Updated tool description with CRITICAL warning about not polling in loop 3. Changed next_steps to explicitly say "DO NOT call again automatically" The agent should now check status once, inform the user, and wait for them to request updates. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8fc54e1 commit 7cf24ef

1 file changed

Lines changed: 28 additions & 12 deletions

File tree

src/agent/tools/platform/get_deployment_status.rs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ impl Tool for GetDeploymentStatusTool {
5555
Returns the current status of a deployment, including progress percentage,
5656
current step, overall status, and optionally the public URL if the service is ready.
5757
58+
**CRITICAL - DO NOT POLL IN A LOOP:**
59+
After checking status, you MUST inform the user and WAIT for them to ask again.
60+
DO NOT call this tool repeatedly in succession. Deployments take 1-3 minutes.
61+
The response includes an "action" field - follow it:
62+
- "STOP_POLLING": Deployment is done (success or failure). Tell the user.
63+
- "INFORM_USER_AND_WAIT": Tell user the current status and wait for them to ask for updates.
64+
5865
**IMPORTANT for Cloud Runner:**
5966
The task may show "completed" when infrastructure is provisioned, but the actual
6067
service build and deployment takes longer. Pass project_id and service_name to
@@ -70,8 +77,8 @@ also check if the service has a public URL (meaning it's actually ready).
7077
- A deployment must have been triggered (use trigger_deployment first)
7178
7279
**Use Cases:**
73-
- Monitor deployment progress after triggering
74-
- Check if a deployment has completed AND is actually serving traffic
80+
- Check deployment status ONCE after triggering, then inform user
81+
- Let user ask for updates when they want them
7582
- Get error details if deployment failed"#
7683
.to_string(),
7784
parameters: json!({
@@ -182,31 +189,40 @@ also check if the service has a public URL (meaning it's actually ready).
182189
}
183190

184191
// Add next steps based on actual status
192+
// IMPORTANT: Guide agent to STOP polling and inform user
185193
if is_failed {
186194
result["next_steps"] = json!([
195+
"STOP - Deployment failed. Inform the user of the error.",
187196
"Review the error message for details",
188197
"Check the deployment configuration",
189-
"Verify the code builds successfully locally",
190-
"Try triggering a new deployment after fixing the issue"
198+
"Verify the code builds successfully locally"
191199
]);
200+
result["action"] = json!("STOP_POLLING");
192201
} else if truly_ready && public_url.is_some() {
193202
result["next_steps"] = json!([
194-
format!("Service is live at: {}", public_url.as_ref().unwrap()),
203+
format!("STOP - Service is live at: {}", public_url.as_ref().unwrap()),
195204
"Deployment completed successfully!",
196-
"Use get_service_logs to view container logs"
205+
"Inform the user their service is ready"
197206
]);
207+
result["action"] = json!("STOP_POLLING");
198208
} else if task_complete && !truly_ready {
199209
result["next_steps"] = json!([
200-
"Infrastructure task completed, but service is still deploying",
201-
"Cloud Runner is building and deploying your container",
202-
"Call get_deployment_status again in 30-60 seconds to check for public_url"
210+
"STOP POLLING - Inform the user that deployment is in progress",
211+
"Infrastructure is ready, Cloud Runner is building the container",
212+
"Tell the user to wait 1-2 minutes, then they can ask you to check status again",
213+
"DO NOT call get_deployment_status again automatically - wait for user to ask"
203214
]);
204-
result["note"] = json!("Task shows 100% but service is still being built/deployed. This is normal for Cloud Runner.");
215+
result["action"] = json!("INFORM_USER_AND_WAIT");
216+
result["estimated_wait"] = json!("1-2 minutes");
217+
result["note"] = json!("Task shows 100% but container is still being built/deployed. This is normal. DO NOT poll repeatedly - inform the user and wait for them to ask for status.");
205218
} else if !task_complete {
206219
result["next_steps"] = json!([
207-
format!("Deployment is {} ({}% complete)", status.overall_status, status.progress),
208-
"Call get_deployment_status again to check progress"
220+
format!("STOP POLLING - Deployment is {} ({}% complete)", status.overall_status, status.progress),
221+
"Inform the user of current progress",
222+
"Tell them to wait and ask again in 30 seconds if they want an update",
223+
"DO NOT call get_deployment_status again automatically"
209224
]);
225+
result["action"] = json!("INFORM_USER_AND_WAIT");
210226
}
211227

212228
serde_json::to_string_pretty(&result)

0 commit comments

Comments
 (0)