-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathInfiniteSessionConfig.java.html
More file actions
161 lines (145 loc) · 7.02 KB
/
Copy pathInfiniteSessionConfig.java.html
File metadata and controls
161 lines (145 loc) · 7.02 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang=""><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>InfiniteSessionConfig.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">GitHub Copilot SDK :: Java</a> > <a href="index.source.html" class="el_package">com.github.copilot.rpc</a> > <span class="el_source">InfiniteSessionConfig.java</span></div><h1>InfiniteSessionConfig.java</h1><pre class="source lang-java linenums">/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot.rpc;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.Optional;
import java.util.OptionalDouble;
/**
* 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)
<span class="fc" id="L35">public class InfiniteSessionConfig {</span>
@JsonProperty("enabled")
private Boolean enabled;
@JsonProperty("backgroundCompactionThreshold")
private Double backgroundCompactionThreshold;
@JsonProperty("bufferExhaustionThreshold")
private Double bufferExhaustionThreshold;
/**
* Gets whether infinite sessions are enabled.
*
* @return an {@link Optional} containing the boolean value, or empty to use
* default (true)
*/
@JsonIgnore
public Optional<Boolean> getEnabled() {
<span class="fc" id="L54"> return Optional.ofNullable(enabled);</span>
}
/**
* 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) {
<span class="fc" id="L67"> this.enabled = enabled;</span>
<span class="fc" id="L68"> return this;</span>
}
/**
* Clears the enabled setting, reverting to the default behavior.
*
* @return this instance for method chaining
*/
public InfiniteSessionConfig clearEnabled() {
<span class="fc" id="L77"> this.enabled = null;</span>
<span class="fc" id="L78"> return this;</span>
}
/**
* Gets the background compaction threshold.
*
* @return an {@link OptionalDouble} containing the threshold (0.0-1.0), or
* empty to use default
*/
@JsonIgnore
public OptionalDouble getBackgroundCompactionThreshold() {
<span class="fc bfc" id="L89" title="All 2 branches covered."> return backgroundCompactionThreshold == null</span>
<span class="fc" id="L90"> ? OptionalDouble.empty()</span>
<span class="fc" id="L91"> : OptionalDouble.of(backgroundCompactionThreshold);</span>
}
/**
* 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) {
<span class="fc" id="L105"> this.backgroundCompactionThreshold = backgroundCompactionThreshold;</span>
<span class="fc" id="L106"> return this;</span>
}
/**
* Clears the backgroundCompactionThreshold setting, reverting to the default
* behavior.
*
* @return this instance for method chaining
*/
public InfiniteSessionConfig clearBackgroundCompactionThreshold() {
<span class="fc" id="L116"> this.backgroundCompactionThreshold = null;</span>
<span class="fc" id="L117"> return this;</span>
}
/**
* Gets the buffer exhaustion threshold.
*
* @return an {@link OptionalDouble} containing the threshold (0.0-1.0), or
* empty to use default
*/
@JsonIgnore
public OptionalDouble getBufferExhaustionThreshold() {
<span class="fc bfc" id="L128" title="All 2 branches covered."> return bufferExhaustionThreshold == null</span>
<span class="fc" id="L129"> ? OptionalDouble.empty()</span>
<span class="fc" id="L130"> : OptionalDouble.of(bufferExhaustionThreshold);</span>
}
/**
* 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) {
<span class="fc" id="L145"> this.bufferExhaustionThreshold = bufferExhaustionThreshold;</span>
<span class="fc" id="L146"> return this;</span>
}
/**
* Clears the bufferExhaustionThreshold setting, reverting to the default
* behavior.
*
* @return this instance for method chaining
*/
public InfiniteSessionConfig clearBufferExhaustionThreshold() {
<span class="fc" id="L156"> this.bufferExhaustionThreshold = null;</span>
<span class="fc" id="L157"> return this;</span>
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.14.202510111229</span></div></body></html>