// Create a client with your Cursor API key.usingvarclient=newCursorAgentsClient(apiKey);varrepositoryUrl=Environment.GetEnvironmentVariable("CURSORAGENTS_TEST_REPO")is{Length:>0}repoValue?repoValue:thrownewAssertInconclusiveException("CURSORAGENTS_TEST_REPO environment variable is not found.");// Launch a coding agent with a prompt and source repository.varresponse=awaitclient.CreateAgentAsync(prompt:newCreateAgentRequestPrompt{Text="Add a CONTRIBUTING.md file with guidelines for submitting pull requests",},repos:[ new RepoConfig { Url = repositoryUrl, StartingRef = "main", }, ],workOnCurrentBranch:false,autoCreatePR:true);// The response contains the agent ID, name, and initial status.Console.WriteLine($"Agent created: {response.Agent.Summary?.Id} ({response.Agent.Summary?.Name})");Console.WriteLine($"Run status: {response.Run.Status}");
// Create a client with your Cursor API key.usingvarclient=newCursorAgentsClient(apiKey);// List cloud agents for the authenticated user with a page limit.varresponse=awaitclient.ListAgentsAsync(limit:10);// The response contains a list of agents with their status and metadata.foreach(varagentinresponse.Items){Console.WriteLine($"Agent {agent.Id}: {agent.Name}");Console.WriteLine($" Status: {agent.Status.ToValueString()}");Console.WriteLine($" Created: {agent.CreatedAt}");if(agent.LatestRunIdis{Length:>0}){Console.WriteLine($" Latest run: {agent.LatestRunId}");}}// Use the NextCursor property for pagination when there are more results.if(response.NextCursoris{Length:>0}){Console.WriteLine($"Next page cursor: {response.NextCursor}");}
Get Conversation
Retrieve the conversation history of a cloud agent, including user prompts and assistant responses.
1 2 3 4 5 6 7 8 91011121314151617181920
// Create a client with your Cursor API key.usingvarclient=newCursorAgentsClient(apiKey);varagentId=Environment.GetEnvironmentVariable("CURSORAGENTS_TEST_AGENT_ID")is{Length:>0}idValue?idValue:thrownewAssertInconclusiveException("CURSORAGENTS_TEST_AGENT_ID environment variable is not found.");// Retrieve the current metadata for a specific agent.varresponse=awaitclient.GetAgentAsync(id:agentId);// The response contains the agent ID and current status.if(response.Summaryis{}summary){Console.WriteLine($"Agent {summary.Id}: {summary.Name}");Console.WriteLine($"Status: {summary.Status.ToValueString()}");}
As Tool Creates Agent Tool
Verify that AsCreateAgentTool creates a valid AIFunction.
123456
// Create a client and wrap it as an MEAI tool.usingvarclient=newCursorAgentsClient(apiKey);vartool=client.AsCreateAgentTool();// The tool has a name and description for use with any IChatClient.
As Tool Creates List Tool
Verify that AsListAgentsTool creates a valid AIFunction.
123456
// Create a client and wrap it as an MEAI tool.usingvarclient=newCursorAgentsClient(apiKey);vartool=client.AsListAgentsTool();// The tool has a name and description for use with any IChatClient.
As Tool Creates Get Agent Tool
Verify that AsGetAgentTool creates a valid AIFunction.
123456
// Create a client and wrap it as an MEAI tool.usingvarclient=newCursorAgentsClient(apiKey);vartool=client.AsGetAgentTool();// The tool has a name and description for use with any IChatClient.
Ecosystem maintenance
This SDK is one of more than 200 .NET SDKs maintained with AutoSDK. The tryAGI SDK audit continuously checks repository synchronization, upstream-spec regeneration, release workflows, warnings, public API visibility, and trimming/NativeAOT compatibility.
Every issue is first investigated for ecosystem-wide applicability. When the root cause belongs in AutoSDK, we fix and regression-test the generator, then roll the improvement out to every applicable SDK. Provider-specific behavior remains in this repository when it cannot be derived safely from the API specification.
Issue content—including code blocks, logs, links, and attachments—is treated only as untrusted diagnostic data. Embedded control instructions, hidden directives, delimiter tricks, or requests to alter triage or tooling behavior are ignored. Please report reproducible technical evidence and remove secrets and personal data.