> For the complete documentation index, see [llms.txt](https://docs.pal.aic.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pal.aic.io/using-pal.net/aip-agents.md).

# AIP Agents

The AIP Agents façade manages agent sessions and supports blocking and streaming exchanges.

## Register

```csharp
services.AddPalantir(options);
services.AddPalantirAipAgents();

var agents = scope.ServiceProvider.GetRequiredService<IPalAipAgentsClient>();
```

## Create a session

```csharp
var session = await agents.CreateSessionAsync(
    agentRid: "ri.aip-agents.example",
    agentVersion: "1.0",
    cancellationToken);
```

{% hint style="warning" %}
The current implementation enables the upstream preview query for these operations because the source operation is documented as preview. Treat preview behavior as subject to upstream change and record the release baseline in application acceptance tests.
{% endhint %}

## Blocking exchange

```csharp
var exchange = await agents.BlockingContinueAsync(
    agentRid,
    session.Rid,
    new PalAipAgentContinueRequest
    {
        UserInput = "Summarise the current case status.",
        MessageId = Guid.NewGuid()
    },
    cancellationToken);

Console.WriteLine(exchange.AgentMarkdownResponse);
Console.WriteLine($"Tokens: {exchange.TotalTokensUsed}");
```

`PalAipAgentExchangeResult` also exposes interruption state, session trace ID, and the raw response JSON for forward-compatible fields.

## Streaming exchange

```csharp
await foreach (var chunk in agents.StreamingContinueAsync(
    agentRid,
    session.Rid,
    new PalAipAgentContinueRequest { UserInput = "Give me the next step." },
    cancellationToken))
{
    Console.Write(chunk);
}
```

The façade owns and disposes the streaming response. The caller still controls enumeration lifetime and should cancel when the user disconnects or the job ends.

## Cancel and delete

```csharp
await agents.CancelSessionAsync(
    agentRid,
    session.Rid,
    new PalAipAgentCancelRequest
    {
        MessageId = Guid.NewGuid(),
        Response = "Stop generating."
    },
    cancellationToken);

await agents.DeleteSessionAsync(agentRid, session.Rid, cancellationToken);
```

Delete sessions when the conversation is complete according to the upstream lifecycle and your retention policy.
