From ee03d47dd42946fea91b1a257202684765467b42 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 4 Dec 2025 22:23:45 +0000 Subject: [PATCH 1/5] Refactor IncludeContents in State to use internal type Defines a new `IncludeContents` type and constants in `internal/llminternal` and updates the `State` struct to use it. This improves type safety and addresses a TODO comment. Internal Refs: - Defined `IncludeContents` type and constants in `internal/llminternal/agent.go`. - Updated `State.IncludeContents` field type. - Updated `llmagent.New` to cast config value to internal type. - Updated `contents_processor.go` to use internal constant. --- agent/llmagent/llmagent.go | 3 +-- internal/llminternal/agent.go | 12 +++++++++++- internal/llminternal/contents_processor.go | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/agent/llmagent/llmagent.go b/agent/llmagent/llmagent.go index aee848ba3..6df2da8c8 100644 --- a/agent/llmagent/llmagent.go +++ b/agent/llmagent/llmagent.go @@ -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: llminternal.IncludeContents(cfg.IncludeContents), Instruction: cfg.Instruction, InstructionProvider: llminternal.InstructionProvider(cfg.InstructionProvider), GlobalInstruction: cfg.GlobalInstruction, diff --git a/internal/llminternal/agent.go b/internal/llminternal/agent.go index b3239ce1e..1f8cb94a4 100644 --- a/internal/llminternal/agent.go +++ b/internal/llminternal/agent.go @@ -33,7 +33,7 @@ type State struct { Tools []tool.Tool Toolsets []tool.Toolset - IncludeContents string + IncludeContents IncludeContents GenerateContentConfig *genai.GenerateContentConfig @@ -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. The llmagent receives the relevant conversation history. + IncludeContentsDefault IncludeContents = "default" +) + func (s *State) internal() *State { return s } func Reveal(a Agent) *State { return a.internal() } diff --git a/internal/llminternal/contents_processor.go b/internal/llminternal/contents_processor.go index 67c8ec21e..2f9d06805 100644 --- a/internal/llminternal/contents_processor.go +++ b/internal/llminternal/contents_processor.go @@ -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 } From b0d34a2de3fb8979a58168f6db093a4e58927cca Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 4 Dec 2025 23:22:31 +0000 Subject: [PATCH 2/5] Refactor IncludeContents to use type alias Updated `agent/llmagent/llmagent.go` to use a type alias for `IncludeContents` that points to the internal type in `internal/llminternal`. This avoids code duplication while maintaining the public API. Internal Refs: - Changed `IncludeContents` in `llmagent.go` to be an alias. - Updated constants to reference `llminternal` constants. --- agent/llmagent/llmagent.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/agent/llmagent/llmagent.go b/agent/llmagent/llmagent.go index 6df2da8c8..2fb42c830 100644 --- a/agent/llmagent/llmagent.go +++ b/agent/llmagent/llmagent.go @@ -276,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 { From 3e5c2f2105e23309c2db48e36786813e864ce1a7 Mon Sep 17 00:00:00 2001 From: Sheing Date: Thu, 4 Dec 2025 19:17:17 -0600 Subject: [PATCH 3/5] Update agent/llmagent/llmagent.go Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- agent/llmagent/llmagent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/llmagent/llmagent.go b/agent/llmagent/llmagent.go index 2fb42c830..a70e3ba40 100644 --- a/agent/llmagent/llmagent.go +++ b/agent/llmagent/llmagent.go @@ -71,7 +71,7 @@ func New(cfg Config) (agent.Agent, error) { DisallowTransferToPeers: cfg.DisallowTransferToPeers, InputSchema: cfg.InputSchema, OutputSchema: cfg.OutputSchema, - IncludeContents: llminternal.IncludeContents(cfg.IncludeContents), +IncludeContents: cfg.IncludeContents, Instruction: cfg.Instruction, InstructionProvider: llminternal.InstructionProvider(cfg.InstructionProvider), GlobalInstruction: cfg.GlobalInstruction, From f94ec5cdf88703f8f7cfe96ec2bfb78034b4ff52 Mon Sep 17 00:00:00 2001 From: Sheing Date: Wed, 10 Dec 2025 17:04:24 -0600 Subject: [PATCH 4/5] Update agent/llmagent/llmagent.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: João Westerberg --- agent/llmagent/llmagent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/llmagent/llmagent.go b/agent/llmagent/llmagent.go index a70e3ba40..5b43cb1fb 100644 --- a/agent/llmagent/llmagent.go +++ b/agent/llmagent/llmagent.go @@ -71,7 +71,7 @@ func New(cfg Config) (agent.Agent, error) { DisallowTransferToPeers: cfg.DisallowTransferToPeers, InputSchema: cfg.InputSchema, OutputSchema: cfg.OutputSchema, -IncludeContents: cfg.IncludeContents, + IncludeContents: cfg.IncludeContents, Instruction: cfg.Instruction, InstructionProvider: llminternal.InstructionProvider(cfg.InstructionProvider), GlobalInstruction: cfg.GlobalInstruction, From 30663936bf5653c60928c0e793ca22a635d2f648 Mon Sep 17 00:00:00 2001 From: Sheing Date: Wed, 10 Dec 2025 17:15:42 -0600 Subject: [PATCH 5/5] Fix typo in IncludeContentsDefault comment --- internal/llminternal/agent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/llminternal/agent.go b/internal/llminternal/agent.go index 1f8cb94a4..f88b10352 100644 --- a/internal/llminternal/agent.go +++ b/internal/llminternal/agent.go @@ -59,7 +59,7 @@ 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. The llmagent receives the relevant conversation history. + // IncludeContentsDefault is enabled by default. It will receives the relevant conversation history. IncludeContentsDefault IncludeContents = "default" )