session: add Checkpoint for typed subflow handoff
This commit is contained in:
parent
b5b2ee43ec
commit
ea4a3084e0
|
|
@ -133,6 +133,22 @@ func newSession(goal string) *Session {
|
|||
return &Session{goal: goal}
|
||||
}
|
||||
|
||||
// Checkpoint forks the session: returns a new Session that inherits the given
|
||||
// TaskState but starts with a clean message history. This enables narrow-context
|
||||
// sub-agents that know what to do without inheriting all parent message noise.
|
||||
func (s *Session) Checkpoint(ts TaskState) *Session {
|
||||
child := &Session{
|
||||
goal: ts.Objective,
|
||||
TaskState: &ts,
|
||||
}
|
||||
// Seed with a user message so the child has a valid initial turn.
|
||||
child.messages = []backend.Message{{
|
||||
Role: "user",
|
||||
Content: ts.render(),
|
||||
}}
|
||||
return child
|
||||
}
|
||||
|
||||
func (s *Session) history() []backend.Message {
|
||||
return s.messages
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue