## StartAgent `client.Agents.StartExecution(ctx, body) (*AgentStartExecutionResponse, error)` **post** `/gitpod.v1.AgentService/StartAgent` Starts (or triggers) an agent run using a provided agent. Use this method to: - Launch an agent based on a known agent ### Examples - Start an agent with a project ID: ```yaml agentId: "b8a64cfa-43e2-4b9d-9fb3-07edc63f5971" codeContext: projectId: "2d22e4eb-31da-467f-882c-27e21550992f" ``` ### Parameters - `body AgentStartExecutionParams` - `AgentID param.Field[string]` - `Annotations param.Field[map[string, string]]` annotations are key-value pairs for tracking external context (e.g., integration session IDs, GitHub issue references). Keys should follow domain/name convention (e.g., "agent-client-session/id"). - `CodeContext param.Field[AgentCodeContext]` - `Mode param.Field[AgentMode]` mode specifies the operational mode for this agent execution If not specified, defaults to AGENT_MODE_EXECUTION - `Name param.Field[string]` - `RunnerID param.Field[string]` runner_id specifies a runner for this agent execution. When set, the agent execution is routed to this runner instead of the runner associated with the environment. - `SessionID param.Field[string]` session_id is the ID of the session this agent execution belongs to. If empty, a new session is created implicitly. - `WorkflowActionID param.Field[string]` workflow_action_id is an optional reference to the workflow execution action that created this agent execution. Used for tracking and event correlation. ### Returns - `type AgentStartExecutionResponse struct{…}` - `AgentExecutionID string` ### Example ```go package main import ( "context" "fmt" "github.com/gitpod-io/gitpod-sdk-go" "github.com/gitpod-io/gitpod-sdk-go/option" ) func main() { client := gitpod.NewClient( option.WithBearerToken("My Bearer Token"), ) response, err := client.Agents.StartExecution(context.TODO(), gitpod.AgentStartExecutionParams{ AgentID: gitpod.F("b8a64cfa-43e2-4b9d-9fb3-07edc63f5971"), CodeContext: gitpod.F(gitpod.AgentCodeContextParam{ ProjectID: gitpod.F("2d22e4eb-31da-467f-882c-27e21550992f"), }), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.AgentExecutionID) } ``` #### Response ```json { "agentExecutionId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" } ```