Delete an agent session
client.Beta.Agents.Sessions.Delete(ctx, sessionID) (*AgentSessionDeleted, error)
DELETE/agents/sessions/{session_id}
Removes a managed agent session from the public API and returns a deletion confirmation. If backend execution has ended, deletion can cancel a still-open public turn and abandon unpublished outputs. Running execution must be cancelled first. Physical cleanup may continue asynchronously. See managing sessions.
Delete an agent session
package main
import (
"context"
"fmt"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
agentSessionDeleted, err := client.Beta.Agents.Sessions.Delete(context.TODO(), "session_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", agentSessionDeleted.ID)
}
{
"id": "id",
"deleted": true,
"object": "agent.session.deleted"
}Returns Examples
{
"id": "id",
"deleted": true,
"object": "agent.session.deleted"
}