forked from github/copilot-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInfiniteSessionConfig.java
More file actions
114 lines (102 loc) · 3.56 KB
/
InfiniteSessionConfig.java
File metadata and controls
114 lines (102 loc) · 3.56 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot.sdk.json;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Configuration for infinite sessions with automatic context compaction and
* workspace persistence.
* <p>
* When enabled, sessions automatically manage context window limits through
* background compaction and persist state to a workspace directory.
*
* <h2>Example Usage</h2>
*
* <pre>{@code
* var infiniteConfig = new InfiniteSessionConfig().setEnabled(true).setBackgroundCompactionThreshold(0.80)
* .setBufferExhaustionThreshold(0.95);
*
* var config = new SessionConfig().setInfiniteSessions(infiniteConfig);
*
* var session = client.createSession(config).get();
* }</pre>
*
* @see SessionConfig#setInfiniteSessions(InfiniteSessionConfig)
* @since 1.0.2
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class InfiniteSessionConfig {
@JsonProperty("enabled")
private Boolean enabled;
@JsonProperty("backgroundCompactionThreshold")
private Double backgroundCompactionThreshold;
@JsonProperty("bufferExhaustionThreshold")
private Double bufferExhaustionThreshold;
/**
* Gets whether infinite sessions are enabled.
*
* @return {@code true} if enabled, {@code null} to use default (true)
*/
public Boolean getEnabled() {
return enabled;
}
/**
* Sets whether infinite sessions are enabled.
* <p>
* Default: true
*
* @param enabled
* {@code true} to enable infinite sessions
* @return this config instance for method chaining
*/
public InfiniteSessionConfig setEnabled(Boolean enabled) {
this.enabled = enabled;
return this;
}
/**
* Gets the background compaction threshold.
*
* @return the threshold (0.0-1.0), or {@code null} to use default
*/
public Double getBackgroundCompactionThreshold() {
return backgroundCompactionThreshold;
}
/**
* Sets the context utilization threshold at which background compaction starts.
* <p>
* Compaction runs asynchronously, allowing the session to continue processing.
* Default: 0.80
*
* @param backgroundCompactionThreshold
* the threshold (0.0-1.0)
* @return this config instance for method chaining
*/
public InfiniteSessionConfig setBackgroundCompactionThreshold(Double backgroundCompactionThreshold) {
this.backgroundCompactionThreshold = backgroundCompactionThreshold;
return this;
}
/**
* Gets the buffer exhaustion threshold.
*
* @return the threshold (0.0-1.0), or {@code null} to use default
*/
public Double getBufferExhaustionThreshold() {
return bufferExhaustionThreshold;
}
/**
* Sets the context utilization threshold at which the session blocks until
* compaction completes.
* <p>
* This prevents context overflow when compaction hasn't finished in time.
* Default: 0.95
*
* @param bufferExhaustionThreshold
* the threshold (0.0-1.0)
* @return this config instance for method chaining
*/
public InfiniteSessionConfig setBufferExhaustionThreshold(Double bufferExhaustionThreshold) {
this.bufferExhaustionThreshold = bufferExhaustionThreshold;
return this;
}
}