Retrieve the conversation history of a cloud agent, including user prompts and assistant responses.
This example assumes using CursorAgents; is in scope and apiKey contains your CursorAgents API key.
1 2 3 4 5 6 7 8 91011121314151617181920212223
// 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 full conversation history for a specific agent.varresponse=awaitclient.GetAgentConversationAsync(id:agentId);// The response contains the agent ID and all messages in chronological order.foreach(varmessageinresponse.Messages){varrole=message.Type==GetAgentConversationResponseMessageType.UserMessage?"User":"Assistant";Console.WriteLine($"[{role}] {message.Text}");}