Skip to content

Commit 33cea27

Browse files
committed
feat(observer): add AgentState and AgentStateService #259
Introduce AgentState data class to manage agent state, including conversation ID, change list, messages, and used tools. Add AgentStateService as a singleton service to hold the current state
1 parent 6956864 commit 33cea27

File tree

1 file changed

+43
-0
lines changed
  • core/src/main/kotlin/cc/unitmesh/devti/observer/agent

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package cc.unitmesh.devti.observer.agent
2+
3+
import cc.unitmesh.devti.agent.tool.AgentTool
4+
import cc.unitmesh.devti.llms.custom.Message
5+
import com.intellij.openapi.components.Service
6+
import com.intellij.util.diff.Diff.Change
7+
import kotlinx.serialization.Contextual
8+
import kotlinx.serialization.Serializable
9+
import java.util.UUID
10+
11+
@Serializable
12+
data class AgentState(
13+
val conversationId: String = UUID.randomUUID().toString(),
14+
@Contextual
15+
val changeList: List<Change> = emptyList(),
16+
17+
val messages: List<Message> = emptyList(),
18+
19+
val usedTools: List<AgentTool> = emptyList(),
20+
)
21+
22+
23+
@Service
24+
class AgentStateService {
25+
var state: AgentState = AgentState()
26+
27+
/**
28+
* Call some LLM to compress it or use some other method to compress the history
29+
*/
30+
fun compressHistory(messages: List<Message>): List<Message> {
31+
return messages
32+
}
33+
}
34+
35+
interface AgentProcessor {
36+
fun process()
37+
}
38+
39+
class HistoryMessageProcessor: AgentProcessor {
40+
override fun process() {
41+
TODO("Not yet implemented")
42+
}
43+
}

0 commit comments

Comments
 (0)