Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1382035
added `SessionFlow` and related
apascal07 Feb 6, 2026
fe91d76
Update main.go
apascal07 Feb 6, 2026
ad323d2
Update main.go
apascal07 Feb 6, 2026
3913771
moved files
apascal07 Feb 6, 2026
15880f5
added `DefineSessionFlowFromPrompt`
apascal07 Feb 6, 2026
e94bca1
removed stream type param
apascal07 Feb 6, 2026
a77fa33
updates
apascal07 Feb 9, 2026
e83af30
cleaned up API naming and behavior
apascal07 Feb 17, 2026
db37102
Update action.go
apascal07 Feb 17, 2026
f4c4ec1
added stream capturing to output
apascal07 Feb 18, 2026
08b09e4
stream out interrupt chunks
apascal07 Feb 18, 2026
c2f55ab
Update genkit.go
apascal07 Feb 18, 2026
30b4afd
Update agent_flow.go
apascal07 Feb 18, 2026
22be814
removed get snapshot action
apascal07 Feb 18, 2026
a009a1b
tagged prompt messages and excluded them
apascal07 Feb 18, 2026
ea742d9
fixed PromptInput -> InputVariables
apascal07 Feb 18, 2026
2ae4bb8
added AgentFlowResult to output final artifacts
apascal07 Feb 18, 2026
787f61a
Update agent_flow.go
apascal07 Feb 18, 2026
d1281d5
removed turn index from snapshot
apascal07 Feb 18, 2026
d6cae44
exposed InputCh and TurnIndex on AgentSession
apascal07 Feb 18, 2026
10bbd03
improvements to API
apascal07 Feb 18, 2026
a687eb6
minor fixes
apascal07 Feb 18, 2026
7c535c4
Update session.go
apascal07 Feb 18, 2026
26f8f7d
added shared schemas for agent types
apascal07 Feb 18, 2026
d9c335a
Update typing.py
apascal07 Feb 18, 2026
fb7f254
various renames
apascal07 Feb 18, 2026
971b668
helper for input variables conversion
apascal07 Feb 19, 2026
3491761
DefinePromptAgent takes in prompt name instead of resolved prompt
apascal07 Feb 19, 2026
b46acce
fixed interrupts streaming
apascal07 Feb 21, 2026
6676882
Update genkit.go
apascal07 Feb 21, 2026
8d99639
added `SetMessages`
apascal07 Feb 21, 2026
3cbec28
added `AgentSession.Result()`
apascal07 Feb 25, 2026
6ac5510
moved from `ai/x` to `ai/exp`
apascal07 Feb 25, 2026
ac39ef9
Update agent.go
apascal07 Feb 25, 2026
5a671bb
added `AgentFlow.Run()` and `AgentFlow.RunText()`
apascal07 Feb 25, 2026
49a19eb
dedupe consecutive identical snapshots
apascal07 Feb 25, 2026
aca712c
renamed agent flow et al to session flow
apascal07 Mar 6, 2026
9c0d629
Update genkit-schema.json
apascal07 Mar 6, 2026
668fc31
renamed files
apascal07 Mar 6, 2026
000b300
Update agent.ts
apascal07 Mar 6, 2026
d82c1a8
Update schemas.config
apascal07 Mar 6, 2026
8e0a8d6
Merge ap/go-bidi and refactor session flow for new type params
apascal07 Mar 13, 2026
b6f5dc0
refactored order of type params
apascal07 Mar 13, 2026
c298aca
Update action.go
apascal07 Mar 13, 2026
aabe1ad
Update session_flow_test.go
apascal07 Mar 30, 2026
e3f6c42
refactored EndTurn bool into TurnEnd struct
apascal07 Apr 17, 2026
434a8d3
fix python
apascal07 Apr 17, 2026
c9fbc31
regenerate genkit-schema.json
apascal07 Apr 17, 2026
57a29d0
regenerate Python schema typing
apascal07 Apr 17, 2026
8709bb0
Update session_flow.go
apascal07 Apr 21, 2026
1761f81
Merge branch 'ap/go-bidi' into ap/go-session-flow
apascal07 Apr 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions go/ai/x/option.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

package aix

import "errors"

// --- SessionFlowOption ---

// SessionFlowOption configures a SessionFlow.
type SessionFlowOption[State any] interface {
applySessionFlow(*sessionFlowOptions[State]) error
}

type sessionFlowOptions[State any] struct {
store SnapshotStore[State]
callback SnapshotCallback[State]
}

func (o *sessionFlowOptions[State]) applySessionFlow(opts *sessionFlowOptions[State]) error {
if o.store != nil {
if opts.store != nil {
return errors.New("cannot set snapshot store more than once (WithSnapshotStore)")
}
opts.store = o.store
}
if o.callback != nil {
if opts.callback != nil {
return errors.New("cannot set snapshot callback more than once (WithSnapshotCallback)")
}
opts.callback = o.callback
}
return nil
}

// WithSnapshotStore sets the store for persisting snapshots.
func WithSnapshotStore[State any](store SnapshotStore[State]) SessionFlowOption[State] {
return &sessionFlowOptions[State]{store: store}
}

// WithSnapshotCallback configures when snapshots are created.
// If not provided and a store is configured, snapshots are always created.
func WithSnapshotCallback[State any](cb SnapshotCallback[State]) SessionFlowOption[State] {
return &sessionFlowOptions[State]{callback: cb}
}

// --- StreamBidiOption ---

// StreamBidiOption configures a StreamBidi call.
type StreamBidiOption[State any] interface {
applyStreamBidi(*streamBidiOptions[State]) error
}

type streamBidiOptions[State any] struct {
state *SessionState[State]
snapshotID string
}

func (o *streamBidiOptions[State]) applyStreamBidi(opts *streamBidiOptions[State]) error {
if o.state != nil {
if opts.state != nil {
return errors.New("cannot set state more than once (WithState)")
}
opts.state = o.state
}
if o.snapshotID != "" {
if opts.snapshotID != "" {
return errors.New("cannot set snapshot ID more than once (WithSnapshotID)")
}
opts.snapshotID = o.snapshotID
}
return nil
}

// WithState sets the initial state for the invocation.
// Use this for client-managed state where the client sends state directly.
func WithState[State any](state *SessionState[State]) StreamBidiOption[State] {
return &streamBidiOptions[State]{state: state}
}

// WithSnapshotID loads state from a persisted snapshot by ID.
// Use this for server-managed state where snapshots are stored.
func WithSnapshotID[State any](id string) StreamBidiOption[State] {
return &streamBidiOptions[State]{snapshotID: id}
}
Loading
Loading