Skip to content

Commit 0127bec

Browse files
authored
Merge pull request #166 from copilot-community-sdk/copilot/add-documentation-for-new-methods
Document missing PR #162 CopilotSession APIs in advanced guide
2 parents b8976d7 + 27ef548 commit 0127bec

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/site/markdown/advanced.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ This guide covers advanced scenarios for extending and customizing your Copilot
1515
- [File Attachments](#File_Attachments)
1616
- [Bring Your Own Key (BYOK)](#Bring_Your_Own_Key_BYOK)
1717
- [Infinite Sessions](#Infinite_Sessions)
18+
- [Manual Compaction](#Manual_Compaction)
1819
- [Compaction Events](#Compaction_Events)
1920
- [MCP Servers](#MCP_Servers)
2021
- [Custom Agents](#Custom_Agents)
22+
- [Programmatic Agent Selection](#Programmatic_Agent_Selection)
2123
- [Skills Configuration](#Skills_Configuration)
2224
- [Loading Skills](#Loading_Skills)
2325
- [Disabling Skills](#Disabling_Skills)
@@ -317,6 +319,14 @@ var session = client.createSession(
317319
var workspace = session.getWorkspacePath();
318320
```
319321

322+
### Manual Compaction
323+
324+
Trigger compaction immediately when you want to reduce context usage before the automatic threshold is reached:
325+
326+
```java
327+
session.compact().get();
328+
```
329+
320330
### Compaction Events
321331

322332
When compaction occurs, the session emits events that you can listen for:
@@ -419,6 +429,24 @@ var session = client.createSession(
419429

420430
See [CustomAgentConfig](apidocs/com/github/copilot/sdk/json/CustomAgentConfig.html) Javadoc for full details.
421431

432+
### Programmatic Agent Selection
433+
434+
You can inspect and switch agents at runtime:
435+
436+
```java
437+
var available = session.listAgents().get();
438+
439+
var current = session.getCurrentAgent().get();
440+
if (current != null) {
441+
System.out.println("Current agent: " + current.name());
442+
}
443+
444+
var selected = session.selectAgent("reviewer").get();
445+
System.out.println("Selected: " + selected.name());
446+
447+
session.deselectAgent().get(); // Return to the default agent
448+
```
449+
422450
---
423451

424452
## Skills Configuration

0 commit comments

Comments
 (0)