What would you like to be added:
I propose adding explicit server-side session deletion to AgentRuntimeClient
in the Python SDK to match the lifecycle behavior CodeInterpreterClient already
has. This includes:
-
Extending ControlPlaneClient (sdk-python/agentcube/clients/control_plane.py)
to support DELETE /v1/agent-runtime/sessions/:sessionId — either by adding a
dedicated delete_agent_runtime_session(session_id) method or by making the
existing delete_session method accept the resource kind. The existing
delete_session path used by CodeInterpreterClient will remain unchanged.
-
Adding optional workload_manager_url and auth_token parameters to
AgentRuntimeClient.__init__ (sdk-python/agentcube/agent_runtime.py) with
the same env-var fallback pattern used by CodeInterpreterClient, so existing
callers that do not need explicit delete are not broken.
-
Adding a stop() method to AgentRuntimeClient that:
- Closes the local data-plane connection.
- Calls the WorkloadManager delete API for sessions the client created itself.
- Does NOT auto-delete sessions that were attached by passing an existing
session_id (to preserve long-running session reuse).
-
Updating AgentRuntimeClient.__exit__ to call stop() instead of close().
-
Updating sdk-python/examples/agent_runtime_usage.py to demonstrate the full
create → invoke → stop lifecycle.
-
Adding tests covering:
- Owned session:
stop() calls the delete endpoint.
- Attached session:
stop() does not auto-delete.
- Context manager:
stop() is called on exit for owned sessions.
The backend route DELETE /v1/agent-runtime/sessions/:sessionId already exists
in pkg/workloadmanager/server.go and uses the shared handleDeleteSandbox
handler. No Go backend changes are needed.
Why is this needed:
Currently AgentRuntimeClient.close() only closes the local HTTP connection —
no WorkloadManager API call is made and the server-side sandbox is never released
through the SDK. CodeInterpreterClient already has this full lifecycle via
stop() which calls DELETE /v1/code-interpreter/sessions/:sessionId.
As agent itself may be long-running (issue #303 is removing the default 8h max
TTL for AgentRuntime), SDK users will have no path to release server-side
resources. The sandbox keeps running until idle-timeout fires or someone manually
cleans up the cluster. CodeInterpreterClient and AgentRuntimeClient should
have a consistent lifecycle contract.
This is a Python SDK-only change. No Go code, no CRD regeneration, no generated
client changes are required.
What would you like to be added:
I propose adding explicit server-side session deletion to
AgentRuntimeClientin the Python SDK to match the lifecycle behavior
CodeInterpreterClientalreadyhas. This includes:
Extending
ControlPlaneClient(sdk-python/agentcube/clients/control_plane.py)to support
DELETE /v1/agent-runtime/sessions/:sessionId— either by adding adedicated
delete_agent_runtime_session(session_id)method or by making theexisting
delete_sessionmethod accept the resource kind. The existingdelete_sessionpath used byCodeInterpreterClientwill remain unchanged.Adding optional
workload_manager_urlandauth_tokenparameters toAgentRuntimeClient.__init__(sdk-python/agentcube/agent_runtime.py) withthe same env-var fallback pattern used by
CodeInterpreterClient, so existingcallers that do not need explicit delete are not broken.
Adding a
stop()method toAgentRuntimeClientthat:session_id(to preserve long-running session reuse).Updating
AgentRuntimeClient.__exit__to callstop()instead ofclose().Updating
sdk-python/examples/agent_runtime_usage.pyto demonstrate the fullcreate → invoke → stop lifecycle.
Adding tests covering:
stop()calls the delete endpoint.stop()does not auto-delete.stop()is called on exit for owned sessions.The backend route
DELETE /v1/agent-runtime/sessions/:sessionIdalready existsin
pkg/workloadmanager/server.goand uses the sharedhandleDeleteSandboxhandler. No Go backend changes are needed.
Why is this needed:
Currently
AgentRuntimeClient.close()only closes the local HTTP connection —no WorkloadManager API call is made and the server-side sandbox is never released
through the SDK.
CodeInterpreterClientalready has this full lifecycle viastop()which callsDELETE /v1/code-interpreter/sessions/:sessionId.As agent itself may be long-running (issue #303 is removing the default 8h max
TTL for AgentRuntime), SDK users will have no path to release server-side
resources. The sandbox keeps running until idle-timeout fires or someone manually
cleans up the cluster.
CodeInterpreterClientandAgentRuntimeClientshouldhave a consistent lifecycle contract.
This is a Python SDK-only change. No Go code, no CRD regeneration, no generated
client changes are required.