Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 4 additions & 5 deletions agent/llmagent/llmagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ func New(cfg Config) (agent.Agent, error) {
DisallowTransferToPeers: cfg.DisallowTransferToPeers,
InputSchema: cfg.InputSchema,
OutputSchema: cfg.OutputSchema,
// TODO: internal type for includeContents
IncludeContents: string(cfg.IncludeContents),
IncludeContents: cfg.IncludeContents,
Instruction: cfg.Instruction,
InstructionProvider: llminternal.InstructionProvider(cfg.InstructionProvider),
GlobalInstruction: cfg.GlobalInstruction,
Expand Down Expand Up @@ -277,13 +276,13 @@ type BeforeToolCallback func(ctx tool.Context, tool tool.Tool, args map[string]a
type AfterToolCallback func(ctx tool.Context, tool tool.Tool, args, result map[string]any, err error) (map[string]any, error)

// IncludeContents controls what parts of prior conversation history is received by llmagent.
type IncludeContents string
type IncludeContents = llminternal.IncludeContents

const (
// IncludeContentsNone makes the llmagent operate solely on its current turn (latest user input + any following agent events).
IncludeContentsNone IncludeContents = "none"
IncludeContentsNone = llminternal.IncludeContentsNone
// IncludeContentsDefault is enabled by default. The llmagent receives the relevant conversation history.
IncludeContentsDefault IncludeContents = "default"
IncludeContentsDefault = llminternal.IncludeContentsDefault
)

type llmAgent struct {
Expand Down
12 changes: 11 additions & 1 deletion internal/llminternal/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type State struct {
Tools []tool.Tool
Toolsets []tool.Toolset

IncludeContents string
IncludeContents IncludeContents

GenerateContentConfig *genai.GenerateContentConfig

Expand All @@ -53,6 +53,16 @@ type State struct {

type InstructionProvider func(ctx agent.ReadonlyContext) (string, error)

// IncludeContents controls what parts of prior conversation history is received by llmagent.
type IncludeContents string

const (
// IncludeContentsNone makes the llmagent operate solely on its current turn (latest user input + any following agent events).
IncludeContentsNone IncludeContents = "none"
// IncludeContentsDefault is enabled by default. It will receives the relevant conversation history.
IncludeContentsDefault IncludeContents = "default"
)

func (s *State) internal() *State { return s }

func Reveal(a Agent) *State { return a.internal() }
2 changes: 1 addition & 1 deletion internal/llminternal/contents_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func ContentsRequestProcessor(ctx agent.InvocationContext, req *model.LLMRequest
return nil // In python, no error is yielded.
}
fn := buildContentsDefault // "" or "default".
if llmAgent.internal().IncludeContents == "none" {
if llmAgent.internal().IncludeContents == IncludeContentsNone {
// Include current turn context only (no conversation history)
fn = buildContentsCurrentTurnContextOnly
}
Expand Down