-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinfinite_sessions.clj
More file actions
32 lines (28 loc) · 1.28 KB
/
infinite_sessions.clj
File metadata and controls
32 lines (28 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(ns infinite-sessions
"Example: Infinite sessions with context compaction.
Demonstrates how to enable infinite sessions so the SDK automatically
compacts older messages when the context window fills up, allowing
arbitrarily long conversations."
(:require [github.copilot-sdk :as copilot]
[github.copilot-sdk.helpers :as h]))
;; See examples/README.md for usage
(def defaults
{:prompts ["What is the capital of France?"
"What is the capital of Japan?"
"What is the capital of Brazil?"]})
(defn run
[{:keys [prompts] :or {prompts (:prompts defaults)}}]
(copilot/with-client-session
[session {:on-permission-request copilot/approve-all
:model "claude-haiku-4.5"
:available-tools []
:system-message {:mode :replace
:content "Answer concisely in one sentence."}
:infinite-sessions {:enabled true
:background-compaction-threshold 0.80
:buffer-exhaustion-threshold 0.95}}]
(doseq [prompt prompts]
(println "Q:" prompt)
(println "🤖:" (h/query prompt :session session))
(println))
(println "✅ All prompts completed with infinite sessions enabled.")))