-
Notifications
You must be signed in to change notification settings - Fork 736
Open
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Summary
client.interactions.cancel(...) consistently returns 404 "Method not found" when using the Gemini Developer API (API key mode).
The same behavior is observed via:
- Python SDK (
python-genai) - Direct REST calls as well
Environment
- SDK: python-genai
- Auth: Gemini Developer API (API key mode)
GOOGLE_API_KEYset
- Endpoint:
https://generativelanguage.googleapis.com/v1beta - Interactions: background agent interaction
- Docs reference:
https://ai.google.dev/gemini-api/docs/interactions#python_2
Minimal Reproduction (Python)
"""
Bug reproduction script for Interactions API cancel endpoint.
This script demonstrates that the cancel endpoint returns
404 "Method not found" for background agent interactions.
Usage (Gemini Developer API / API key mode):
export GOOGLE_API_KEY=YOUR_API_KEY
"""
import time
from google import genai
client = genai.Client()
# Create background interaction
print("[CREATE] Creating background interaction...")
interaction = client.interactions.create(
agent="deep-research-pro-preview-12-2025",
input="Research quantum computing",
background=True,
)
print(f" Interaction ID: {interaction.id}")
print(f" Status: {interaction.status}")
# Give the interaction some time to run
print("\n[SLEEP] Waiting 10 seconds...")
time.sleep(10)
# Attempt to cancel
print("\n[CANCEL] Attempting to cancel...")
try:
cancelled = client.interactions.cancel(id=interaction.id)
print(f" Cancel SUCCESS! Status: {cancelled.status}")
except Exception as e:
print(f" Cancel FAILED: {e}")
# Wait and re-check status
print("\n[SLEEP] Waiting 5 seconds...")
time.sleep(5)
print("\n[GET] Getting status after cancel attempt...")
fetched = client.interactions.get(id=interaction.id)
print(f" Status: {fetched.status}")
# Cleanup
print("\n[DELETE] Deleting interaction...")
try:
client.interactions.delete(id=interaction.id)
print(" Delete SUCCESS!")
except Exception as e:
print(f" Delete FAILED: {e}")
# Verify deletion
print("\n[VERIFY] Verifying deletion...")
try:
client.interactions.get(id=interaction.id)
print(" Interaction still exists (unexpected)")
except Exception as e:
print(f" Interaction deleted (expected): {e}")
print("\n[DONE] Test complete.")Expected Behavior
client.interactions.cancel(id=...)should return the interaction with statuscancelled
Actual Behavior
- Returns
404 - Method not found - Status remains
in_progressafter cancel attempt
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.