Skip to content

armgit / ax

Public Imported from GitHub
0

Agent Executor (AX) is Google's open agentic orchestration runtime

Go

Switch to Interactions ToolCallContent and ToolResultContent (#205)

Jaana Dogan1bc19557914e
diff --git a/cmd/ax/exec.go b/cmd/ax/exec.go
index 1797f3d..1c09e83 100644
--- a/cmd/ax/exec.go
+++ b/cmd/ax/exec.go
@@ -107,7 +107,7 @@ func execLoop(ctx context.Context, id string, agentID string, input string, last
{
Role: "user",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: input,
},
@@ -140,7 +140,7 @@ func execLoop(ctx context.Context, id string, agentID string, input string, last
decision = []*proto.Message{{
Role: "user",
Content: &proto.Content{
- Content: &proto.Content_Confirmation{
+ Type: &proto.Content_Confirmation{
Confirmation: &proto.ConfirmationContent{
Id: conf.Id,
Decision: &proto.ConfirmationContent_Approval{
@@ -154,7 +154,7 @@ func execLoop(ctx context.Context, id string, agentID string, input string, last
decision = []*proto.Message{{
Role: "user",
Content: &proto.Content{
- Content: &proto.Content_Confirmation{
+ Type: &proto.Content_Confirmation{
Confirmation: &proto.ConfirmationContent{
Id: conf.Id,
Decision: &proto.ConfirmationContent_Decline{
@@ -193,7 +193,7 @@ func execLoop(ctx context.Context, id string, agentID string, input string, last
{
Role: "user",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: input,
},
@@ -294,18 +294,23 @@ func displayContents(d *internal.Display, contents []*proto.Message) {
if content == nil {
continue
}
- switch o := content.Content.(type) {
+ switch o := content.Type.(type) {
case *proto.Content_Text:
d.DisplayOutput(o.Text.Text)
case *proto.Content_Confirmation:
// Let the confirmation prompt handle displaying the question.
- case *proto.Content_FunctionCall:
+ case *proto.Content_ToolCall:
// No-op for cleaner CLI logs
- case *proto.Content_FunctionResponse:
+ case *proto.Content_ToolResult:
// Only print if the tool returned an error, otherwise skip
- respMap := o.FunctionResponse.Response.AsMap()
- if errStr, ok := respMap["error"]; ok {
- d.DisplayOutput(fmt.Sprintf("\n[TOOL ERROR for %s]\n%v\n", o.FunctionResponse.Name, errStr))
+ tr := o.ToolResult
+ if fr := tr.GetFunctionResult(); fr != nil {
+ if fr.GetResponse() != nil {
+ respMap := fr.GetResponse().AsMap()
+ if errStr, ok := respMap["error"]; ok {
+ d.DisplayOutput(fmt.Sprintf("\n[TOOL ERROR for %s]\n%v\n", fr.Name, errStr))
+ }
+ }
}
default:
d.DisplayOutput(fmt.Sprintf("unknown output type: %v", o))
diff --git a/examples/k8s_sandbox_agent/main.go b/examples/k8s_sandbox_agent/main.go
index ad8c098..6032e05 100644
--- a/examples/k8s_sandbox_agent/main.go
+++ b/examples/k8s_sandbox_agent/main.go
@@ -72,7 +72,7 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, pro
outputs = append(outputs, &proto.Message{
Role: "agent",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "Hey, I'm your sandbox agent.\n",
},
@@ -82,7 +82,7 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, pro
outputs = append(outputs, &proto.Message{
Role: "agent",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: fmt.Sprintf("here is your upper case text: %s", upper),
},
diff --git a/examples/k8s_sandbox_agent/main_test.go b/examples/k8s_sandbox_agent/main_test.go
index 4307ba5..e1b0dc0 100644
--- a/examples/k8s_sandbox_agent/main_test.go
+++ b/examples/k8s_sandbox_agent/main_test.go
@@ -28,7 +28,7 @@ func TestExtractLatestPayload(t *testing.T) {
{
Role: "user",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{Text: "old user prompt"},
},
},
@@ -36,7 +36,7 @@ func TestExtractLatestPayload(t *testing.T) {
{
Role: "agent",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{Text: "old agent response"},
},
},
@@ -44,7 +44,7 @@ func TestExtractLatestPayload(t *testing.T) {
{
Role: "user",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{Text: "find this text plz plz plz"},
},
},
@@ -52,9 +52,13 @@ func TestExtractLatestPayload(t *testing.T) {
{
Role: "agent",
Content: &proto.Content{
- Content: &proto.Content_FunctionCall{
- FunctionCall: &proto.FunctionCallContent{
- Name: "uppercase-agent",
+ Type: &proto.Content_ToolCall{
+ ToolCall: &proto.ToolCallContent{
+ Type: &proto.ToolCallContent_FunctionCall{
+ FunctionCall: &proto.FunctionCallContent{
+ Name: "uppercase-agent",
+ },
+ },
},
},
},
@@ -82,7 +86,7 @@ func TestExtractLatestPayload(t *testing.T) {
outputs = append(outputs, &proto.Message{
Role: "agent",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "Hey, I'm your sandbox agent.\n",
},
@@ -92,7 +96,7 @@ func TestExtractLatestPayload(t *testing.T) {
outputs = append(outputs, &proto.Message{
Role: "agent",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: fmt.Sprintf("here is your upper case text: %s", upper),
},
diff --git a/examples/remote_agent/main.go b/examples/remote_agent/main.go
index c61a186..6c2186f 100644
--- a/examples/remote_agent/main.go
+++ b/examples/remote_agent/main.go
@@ -73,7 +73,7 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, pro
responseMsg := &proto.Message{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: responseText,
},
diff --git a/internal/agent/colab.go b/internal/agent/colab.go
index 7c2d6e5..88e9edf 100644
--- a/internal/agent/colab.go
+++ b/internal/agent/colab.go
@@ -460,7 +460,7 @@ func (a *ColabAgent) runColabExec(ctx context.Context, sessionName, command stri
Messages: []*proto.Message{{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{Text: line},
},
},
diff --git a/internal/agent/colab_test.go b/internal/agent/colab_test.go
index e0ba4a0..2fc1f3e 100644
--- a/internal/agent/colab_test.go
+++ b/internal/agent/colab_test.go
@@ -68,7 +68,7 @@ func TestLastUserText(t *testing.T) {
msg := func(role, s string) *proto.Message {
return &proto.Message{
Role: role,
- Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: s}}},
+ Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: s}}},
}
}
@@ -542,6 +542,6 @@ func writeTempFile(t *testing.T, name, content string) string {
func userText(s string) *proto.Message {
return &proto.Message{
Role: "user",
- Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: s}}},
+ Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: s}}},
}
}
diff --git a/internal/controller/controller_test.go b/internal/controller/controller_test.go
index 7afac36..5769bdd 100644
--- a/internal/controller/controller_test.go
+++ b/internal/controller/controller_test.go
@@ -40,7 +40,7 @@ func TestController_Exec_ResumptionAndIDGeneration(t *testing.T) {
{
Role: "user",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{Text: "hello"},
},
},
@@ -102,7 +102,7 @@ func TestController_Exec_ResumptionAndIDGeneration(t *testing.T) {
}
// Also populate messages in conversation log to simulate completion.
log.AllEvents[len(log.AllEvents)-1].Messages = []*proto.Message{
- {Role: "user", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "hello"}}}},
+ {Role: "user", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "hello"}}}},
}
log.AllEvents[len(log.AllEvents)-1].State = proto.State_STATE_COMPLETED
@@ -131,7 +131,7 @@ func TestController_Exec_LastSeq_Empty(t *testing.T) {
ConversationId: cid,
Seq: 1,
Messages: []*proto.Message{
- {Role: "user", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 1"}}}},
+ {Role: "user", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 1"}}}},
},
State: proto.State_STATE_COMPLETED,
},
@@ -139,7 +139,7 @@ func TestController_Exec_LastSeq_Empty(t *testing.T) {
ConversationId: cid,
Seq: 2,
Messages: []*proto.Message{
- {Role: "assistant", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 2"}}}},
+ {Role: "assistant", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 2"}}}},
},
State: proto.State_STATE_COMPLETED,
},
@@ -186,7 +186,7 @@ func TestController_Exec_LastSeq(t *testing.T) {
ConversationId: cid,
Seq: 1,
Messages: []*proto.Message{
- {Role: "user", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 1"}}}},
+ {Role: "user", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 1"}}}},
},
State: proto.State_STATE_COMPLETED,
},
@@ -194,7 +194,7 @@ func TestController_Exec_LastSeq(t *testing.T) {
ConversationId: cid,
Seq: 2,
Messages: []*proto.Message{
- {Role: "assistant", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 2"}}}},
+ {Role: "assistant", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 2"}}}},
},
State: proto.State_STATE_COMPLETED,
},
@@ -257,7 +257,7 @@ func TestController_Exec_WaitsForConfirmation(t *testing.T) {
questionMsg := &proto.Message{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Confirmation{
+ Type: &proto.Content_Confirmation{
Confirmation: &proto.ConfirmationContent{
Question: "Are you sure?",
},
@@ -330,7 +330,7 @@ func TestController_Exec_InternalOnly(t *testing.T) {
// Emit internal-only message
if err := o(&proto.AgentOutputs{
Messages: []*proto.Message{
- {Role: "assistant", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "internal message"}}}},
+ {Role: "assistant", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "internal message"}}}},
},
InternalOnly: true,
}); err != nil {
@@ -339,7 +339,7 @@ func TestController_Exec_InternalOnly(t *testing.T) {
// Emit regular message
return o(&proto.AgentOutputs{
Messages: []*proto.Message{
- {Role: "assistant", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "public message"}}}},
+ {Role: "assistant", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "public message"}}}},
},
})
},
@@ -367,7 +367,7 @@ func TestController_Exec_InternalOnly(t *testing.T) {
err = c.Exec(ctx, &proto.ExecRequest{
ConversationId: cid,
Inputs: []*proto.Message{
- {Role: "user", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "hello"}}}},
+ {Role: "user", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "hello"}}}},
},
}, handler)
if err != nil {
diff --git a/internal/controller/executor/executor_test.go b/internal/controller/executor/executor_test.go
index f15dcb6..b3a2f94 100644
--- a/internal/controller/executor/executor_test.go
+++ b/internal/controller/executor/executor_test.go
@@ -201,7 +201,7 @@ func TestConfirmation(t *testing.T) {
Messages: []*proto.Message{{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_Confirmation{
+ Type: &proto.Content_Confirmation{
Confirmation: &proto.ConfirmationContent{Id: confID, Question: "proceed?"},
},
},
@@ -239,7 +239,7 @@ func TestConfirmation(t *testing.T) {
approval := &proto.Message{
Role: "user",
Content: &proto.Content{
- Content: &proto.Content_Confirmation{
+ Type: &proto.Content_Confirmation{
Confirmation: &proto.ConfirmationContent{
Id: confID,
Decision: &proto.ConfirmationContent_Approval{
@@ -341,7 +341,7 @@ func TestResumeConfirmation(t *testing.T) {
msg := &proto.Message{
Content: &proto.Content{
- Content: &proto.Content_Confirmation{
+ Type: &proto.Content_Confirmation{
Confirmation: &proto.ConfirmationContent{
Id: "test-conf-id",
Question: "proceed?",
@@ -366,7 +366,7 @@ func TestResumeConfirmation(t *testing.T) {
// "Hello!" is responded with a confirmation request.
Messages: []*proto.Message{{
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "awesome!",
},
@@ -429,7 +429,7 @@ func TestResumeConfirmation(t *testing.T) {
Messages: []*proto.Message{
{
Content: &proto.Content{
- Content: &proto.Content_Confirmation{
+ Type: &proto.Content_Confirmation{
Confirmation: &proto.ConfirmationContent{
Id: "test-conf-id",
Decision: &proto.ConfirmationContent_Approval{
diff --git a/internal/controller/executor/sqlite_test.go b/internal/controller/executor/sqlite_test.go
index 185ecb3..7e1caeb 100644
--- a/internal/controller/executor/sqlite_test.go
+++ b/internal/controller/executor/sqlite_test.go
@@ -74,7 +74,7 @@ func TestSQLiteEventLog_AppendAndEvents(t *testing.T) {
State: proto.State_STATE_PENDING,
Timestamp: timestamppb.Now(),
Inputs: []*proto.Message{
- {Role: "user", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "hello"}}}},
+ {Role: "user", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "hello"}}}},
},
}
diff --git a/internal/controller/executor/util.go b/internal/controller/executor/util.go
index eb66e4c..ddf0f27 100644
--- a/internal/controller/executor/util.go
+++ b/internal/controller/executor/util.go
@@ -41,7 +41,7 @@ func text(role, s string) *proto.Message {
return &proto.Message{
Role: role,
Content: &proto.Content{
- Content: &proto.Content_Text{Text: &proto.TextContent{Text: s}},
+ Type: &proto.Content_Text{Text: &proto.TextContent{Text: s}},
},
}
}
diff --git a/internal/controller/gemini.go b/internal/controller/gemini.go
index 4ff5728..c4ad775 100644
--- a/internal/controller/gemini.go
+++ b/internal/controller/gemini.go
@@ -119,7 +119,7 @@ func (a *GeminiAgent) Connect(ctx context.Context, execID string, start *proto.A
Messages: []*proto.Message{{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{Text: part.Text},
},
},
@@ -196,11 +196,15 @@ func (t *BashTool) HandleCall(ctx context.Context, fc *genai.FunctionCall, o age
{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_FunctionCall{
- FunctionCall: &proto.FunctionCallContent{
- Id: fc.ID,
- Name: fc.Name,
- Args: argsStruct,
+ Type: &proto.Content_ToolCall{
+ ToolCall: &proto.ToolCallContent{
+ Id: fc.ID,
+ Type: &proto.ToolCallContent_FunctionCall{
+ FunctionCall: &proto.FunctionCallContent{
+ Name: fc.Name,
+ Arguments: argsStruct,
+ },
+ },
},
},
},
@@ -208,7 +212,7 @@ func (t *BashTool) HandleCall(ctx context.Context, fc *genai.FunctionCall, o age
{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_Confirmation{
+ Type: &proto.Content_Confirmation{
Confirmation: &proto.ConfirmationContent{
Id: fc.ID,
Question: fmt.Sprintf("Can I run %q?", command),
@@ -229,10 +233,14 @@ func (t *BashTool) HandleExecute(ctx context.Context, fc *genai.FunctionCall, ap
{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_FunctionResponse{
- FunctionResponse: &proto.FunctionResponseContent{
- Name: fc.Name,
- Id: fc.ID,
+ Type: &proto.Content_ToolResult{
+ ToolResult: &proto.ToolResultContent{
+ CallId: fc.ID,
+ Type: &proto.ToolResultContent_FunctionResult{
+ FunctionResult: &proto.FunctionResultContent{
+ Name: fc.Name,
+ },
+ },
},
},
},
@@ -240,7 +248,7 @@ func (t *BashTool) HandleExecute(ctx context.Context, fc *genai.FunctionCall, ap
{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "Okay.",
},
@@ -264,11 +272,17 @@ func (t *BashTool) HandleExecute(ctx context.Context, fc *genai.FunctionCall, ap
{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_FunctionResponse{
- FunctionResponse: &proto.FunctionResponseContent{
- Name: fc.Name,
- Response: respStruct,
- Id: fc.ID,
+ Type: &proto.Content_ToolResult{
+ ToolResult: &proto.ToolResultContent{
+ CallId: fc.ID,
+ Type: &proto.ToolResultContent_FunctionResult{
+ FunctionResult: &proto.FunctionResultContent{
+ Name: fc.Name,
+ Result: &proto.FunctionResultContent_Response{
+ Response: respStruct,
+ },
+ },
+ },
},
},
},
@@ -276,7 +290,7 @@ func (t *BashTool) HandleExecute(ctx context.Context, fc *genai.FunctionCall, ap
{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: output,
},
@@ -338,11 +352,15 @@ func (t *SkillsTool) HandleCall(ctx context.Context, fc *genai.FunctionCall, o a
{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_FunctionCall{
- FunctionCall: &proto.FunctionCallContent{
- Id: fc.ID,
- Name: fc.Name,
- Args: argsStruct,
+ Type: &proto.Content_ToolCall{
+ ToolCall: &proto.ToolCallContent{
+ Id: fc.ID,
+ Type: &proto.ToolCallContent_FunctionCall{
+ FunctionCall: &proto.FunctionCallContent{
+ Name: fc.Name,
+ Arguments: argsStruct,
+ },
+ },
},
},
},
@@ -350,7 +368,7 @@ func (t *SkillsTool) HandleCall(ctx context.Context, fc *genai.FunctionCall, o a
{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_Confirmation{
+ Type: &proto.Content_Confirmation{
Confirmation: &proto.ConfirmationContent{
Id: fc.ID,
Question: question,
@@ -390,11 +408,17 @@ func (t *SkillsTool) HandleExecute(ctx context.Context, fc *genai.FunctionCall,
{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_FunctionResponse{
- FunctionResponse: &proto.FunctionResponseContent{
- Name: fc.Name,
- Response: respStruct,
- Id: fc.ID,
+ Type: &proto.Content_ToolResult{
+ ToolResult: &proto.ToolResultContent{
+ CallId: fc.ID,
+ Type: &proto.ToolResultContent_FunctionResult{
+ FunctionResult: &proto.FunctionResultContent{
+ Name: fc.Name,
+ Result: &proto.FunctionResultContent_Response{
+ Response: respStruct,
+ },
+ },
+ },
},
},
},
@@ -412,10 +436,14 @@ func (t *SkillsTool) HandleExecute(ctx context.Context, fc *genai.FunctionCall,
{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_FunctionResponse{
- FunctionResponse: &proto.FunctionResponseContent{
- Name: fc.Name,
- Id: fc.ID,
+ Type: &proto.Content_ToolResult{
+ ToolResult: &proto.ToolResultContent{
+ CallId: fc.ID,
+ Type: &proto.ToolResultContent_FunctionResult{
+ FunctionResult: &proto.FunctionResultContent{
+ Name: fc.Name,
+ },
+ },
},
},
},
@@ -423,7 +451,7 @@ func (t *SkillsTool) HandleExecute(ctx context.Context, fc *genai.FunctionCall,
{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "Okay.",
},
@@ -460,11 +488,17 @@ func (t *SkillsTool) HandleExecute(ctx context.Context, fc *genai.FunctionCall,
{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_FunctionResponse{
- FunctionResponse: &proto.FunctionResponseContent{
- Name: fc.Name,
- Response: respStruct,
- Id: fc.ID,
+ Type: &proto.Content_ToolResult{
+ ToolResult: &proto.ToolResultContent{
+ CallId: fc.ID,
+ Type: &proto.ToolResultContent_FunctionResult{
+ FunctionResult: &proto.FunctionResultContent{
+ Name: fc.Name,
+ Result: &proto.FunctionResultContent_Response{
+ Response: respStruct,
+ },
+ },
+ },
},
},
},
@@ -472,7 +506,7 @@ func (t *SkillsTool) HandleExecute(ctx context.Context, fc *genai.FunctionCall,
{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: output,
},
diff --git a/internal/controller/gemini_planner.go b/internal/controller/gemini_planner.go
index 5878ebe..4267464 100644
--- a/internal/controller/gemini_planner.go
+++ b/internal/controller/gemini_planner.go
@@ -209,7 +209,7 @@ func (p *geminiPlannerAgent) process(ctx context.Context, start *proto.AgentStar
Messages: []*proto.Message{{
Role: "model",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{Text: part.Text},
},
},
@@ -257,14 +257,16 @@ func (p *geminiPlannerAgent) handleConfirmationAnswer(inputs []*proto.Message) (
var fc *genai.FunctionCall
for _, input := range inputs {
content := input.GetContent()
- if content.GetFunctionCall() == nil {
+ tc := content.GetToolCall()
+ if tc == nil || tc.GetFunctionCall() == nil {
continue
}
- if fn := content.GetFunctionCall(); fn != nil && fn.Id == conf.Id {
+ if tc.Id == conf.Id {
+ fn := tc.GetFunctionCall()
fc = &genai.FunctionCall{
ID: conf.Id,
Name: fn.Name,
- Args: fn.Args.AsMap(),
+ Args: fn.Arguments.AsMap(),
}
break
}
@@ -278,10 +280,11 @@ func (p *geminiPlannerAgent) handleConfirmationAnswer(inputs []*proto.Message) (
// Otherwise, we will execute the function call forever.
for _, input := range inputs {
content := input.GetContent()
- if content.GetFunctionResponse() == nil {
+ tr := content.GetToolResult()
+ if tr == nil || tr.GetFunctionResult() == nil {
continue
}
- if fr := content.GetFunctionResponse(); fr != nil && fr.Id == fc.ID {
+ if tr.CallId == fc.ID {
// We executed this previously.
// There is nothing more to execute.
return nil, false
@@ -337,7 +340,7 @@ func protoToContents(inputs []*proto.Message) []*genai.Content {
continue
}
- switch m := content.Content.(type) {
+ switch m := content.Type.(type) {
case *proto.Content_Text:
contents = append(contents, &genai.Content{
Role: role,
@@ -355,33 +358,43 @@ func protoToContents(inputs []*proto.Message) []*genai.Content {
case *proto.ConfirmationContent_Approval:
// shouldn't be sent to Gemini
}
- case *proto.Content_FunctionCall:
- contents = append(contents, &genai.Content{
- Role: "model",
- Parts: []*genai.Part{
- {
- ThoughtSignature: m.FunctionCall.ThoughtSignature,
- FunctionCall: &genai.FunctionCall{
- ID: m.FunctionCall.Id,
- Name: m.FunctionCall.Name,
- Args: m.FunctionCall.Args.AsMap(),
+ case *proto.Content_ToolCall:
+ tc := m.ToolCall
+ if fc := tc.GetFunctionCall(); fc != nil {
+ contents = append(contents, &genai.Content{
+ Role: "model",
+ Parts: []*genai.Part{
+ {
+ ThoughtSignature: tc.Signature,
+ FunctionCall: &genai.FunctionCall{
+ ID: tc.Id,
+ Name: fc.Name,
+ Args: fc.Arguments.AsMap(),
+ },
},
},
- },
- })
- case *proto.Content_FunctionResponse:
- contents = append(contents, &genai.Content{
- Role: "user",
- Parts: []*genai.Part{
- {
- FunctionResponse: &genai.FunctionResponse{
- ID: m.FunctionResponse.Id,
- Name: m.FunctionResponse.Name,
- Response: m.FunctionResponse.Response.AsMap(),
+ })
+ }
+ case *proto.Content_ToolResult:
+ tr := m.ToolResult
+ if fr := tr.GetFunctionResult(); fr != nil {
+ var respMap map[string]any
+ if fr.GetResponse() != nil {
+ respMap = fr.GetResponse().AsMap()
+ }
+ contents = append(contents, &genai.Content{
+ Role: "user",
+ Parts: []*genai.Part{
+ {
+ FunctionResponse: &genai.FunctionResponse{
+ ID: tr.CallId,
+ Name: fr.Name,
+ Response: respMap,
+ },
},
},
- },
- })
+ })
+ }
}
// TODO(jbd): Handle other content types (e.g., images, files)
}
diff --git a/internal/multi_test.go b/internal/multi_test.go
index 99c22d7..2e47317 100644
--- a/internal/multi_test.go
+++ b/internal/multi_test.go
@@ -96,7 +96,7 @@ func TestMulti(t *testing.T) {
{
Role: "user",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: input,
},
@@ -160,7 +160,7 @@ func createLocalAgent(transform func(string) string) (*agent.LocalAgent, error)
{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: transform(textContent.Text),
},
@@ -200,7 +200,7 @@ func (m *mockPlanner) Connect(ctx context.Context, execID string, start *proto.A
inputs := append(start.Messages, &proto.Message{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{Text: "oRanGe"},
},
},
@@ -217,7 +217,7 @@ func (m *mockPlanner) Connect(ctx context.Context, execID string, start *proto.A
inputs := append(start.Messages, &proto.Message{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{Text: lastText},
},
},
@@ -234,7 +234,7 @@ func (m *mockPlanner) Connect(ctx context.Context, execID string, start *proto.A
inputs := append(start.Messages, &proto.Message{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{Text: lastText},
},
},
@@ -252,7 +252,7 @@ func (m *mockPlanner) Connect(ctx context.Context, execID string, start *proto.A
Messages: []*proto.Message{{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "Final Result: " + lastText,
},
diff --git a/internal/testagent/agent.go b/internal/testagent/agent.go
index 5503d42..1e1b4f1 100644
--- a/internal/testagent/agent.go
+++ b/internal/testagent/agent.go
@@ -55,7 +55,7 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.A
{
Role: "user",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "Generate Cloud Run Python server code. Only show Python code, the output should be deployable as a server. We will deploy it to Kubernetes.",
},
@@ -134,7 +134,7 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.A
Messages: []*proto.Message{{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "One last step, a summary...",
},
@@ -149,7 +149,7 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.A
history = append(history, &proto.Message{
Role: "user",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "Summarize what we did, and list links to the final deployment endpoints. Give instructions how to revert the deployments if needed",
},
@@ -195,7 +195,7 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
Messages: []*proto.Message{{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: fmt.Sprintf("Picked %v region(s) for deployment.", strings.Join(regions, ",")),
},
@@ -214,7 +214,7 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
{
Role: "user",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "Provide a mirror to the region if the image doesn't exist.",
},
@@ -231,7 +231,7 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
Messages: []*proto.Message{{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "* Deploying to " + region + ", this may take a while...",
},
@@ -245,7 +245,7 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
Messages: []*proto.Message{{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "* kubectl apply -f deployment.yaml",
},
@@ -261,7 +261,7 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
Messages: []*proto.Message{{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: fmt.Sprintf("* Deployment complete. You can access the service at https://%v.test.services.acme.com", region),
},
@@ -293,7 +293,7 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
Messages: []*proto.Message{{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Confirmation{
+ Type: &proto.Content_Confirmation{
Confirmation: &proto.ConfirmationContent{
Id: confID,
Question: fmt.Sprintf("Picked %v region(s) to deploy, continue?", strings.Join(config.Regions, ",")),
diff --git a/internal/testagent/docker.go b/internal/testagent/docker.go
index 3777c04..da6f0d2 100644
--- a/internal/testagent/docker.go
+++ b/internal/testagent/docker.go
@@ -29,7 +29,7 @@ func (a *DockerBuilderAgent) Connect(ctx context.Context, execID string, start *
Messages: []*proto.Message{{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "Building the docker image now...",
},
@@ -43,7 +43,7 @@ func (a *DockerBuilderAgent) Connect(ctx context.Context, execID string, start *
Messages: []*proto.Message{{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "* us-central1-docker.pkg.dev/acme/test/test:latest is built and is ready to push.",
},
@@ -57,7 +57,7 @@ func (a *DockerBuilderAgent) Connect(ctx context.Context, execID string, start *
Messages: []*proto.Message{{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "* The container image is pushed.",
},
@@ -84,7 +84,7 @@ func (a *DockerMirrorAgent) Connect(ctx context.Context, execID string, start *p
Messages: []*proto.Message{{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "* Starting pushing docker image now...",
},
@@ -98,7 +98,7 @@ func (a *DockerMirrorAgent) Connect(ctx context.Context, execID string, start *p
Messages: []*proto.Message{{
Role: "assistant",
Content: &proto.Content{
- Content: &proto.Content_Text{
+ Type: &proto.Content_Text{
Text: &proto.TextContent{
Text: "* The container image is mirrored",
},
diff --git a/proto/content.pb.go b/proto/content.pb.go
index 97257e4..386adcb 100644
--- a/proto/content.pb.go
+++ b/proto/content.pb.go
@@ -267,30 +267,32 @@ func (*ConfirmationContent_Approval) isConfirmationContent_Decision() {}
func (*ConfirmationContent_Decline) isConfirmationContent_Decision() {}
-type FunctionCallContent struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- Args *structpb.Struct `protobuf:"bytes,2,opt,name=args,proto3" json:"args,omitempty"`
- Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`
- ThoughtSignature []byte `protobuf:"bytes,4,opt,name=thought_signature,json=thoughtSignature,proto3" json:"thought_signature,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+type ToolCallContent struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // A unique ID for this specific tool call.
+ Signature []byte `protobuf:"bytes,9,opt,name=signature,proto3" json:"signature,omitempty"` // A signature hash for backend validation.
+ // Types that are valid to be assigned to Type:
+ //
+ // *ToolCallContent_FunctionCall
+ Type isToolCallContent_Type `protobuf_oneof:"type"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
-func (x *FunctionCallContent) Reset() {
- *x = FunctionCallContent{}
+func (x *ToolCallContent) Reset() {
+ *x = ToolCallContent{}
mi := &file_proto_content_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
-func (x *FunctionCallContent) String() string {
+func (x *ToolCallContent) String() string {
return protoimpl.X.MessageStringOf(x)
}
-func (*FunctionCallContent) ProtoMessage() {}
+func (*ToolCallContent) ProtoMessage() {}
-func (x *FunctionCallContent) ProtoReflect() protoreflect.Message {
+func (x *ToolCallContent) ProtoReflect() protoreflect.Message {
mi := &file_proto_content_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -302,62 +304,77 @@ func (x *FunctionCallContent) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
-// Deprecated: Use FunctionCallContent.ProtoReflect.Descriptor instead.
-func (*FunctionCallContent) Descriptor() ([]byte, []int) {
+// Deprecated: Use ToolCallContent.ProtoReflect.Descriptor instead.
+func (*ToolCallContent) Descriptor() ([]byte, []int) {
return file_proto_content_proto_rawDescGZIP(), []int{4}
}
-func (x *FunctionCallContent) GetName() string {
+func (x *ToolCallContent) GetId() string {
if x != nil {
- return x.Name
+ return x.Id
}
return ""
}
-func (x *FunctionCallContent) GetArgs() *structpb.Struct {
+func (x *ToolCallContent) GetSignature() []byte {
if x != nil {
- return x.Args
+ return x.Signature
}
return nil
}
-func (x *FunctionCallContent) GetId() string {
+func (x *ToolCallContent) GetType() isToolCallContent_Type {
if x != nil {
- return x.Id
+ return x.Type
}
- return ""
+ return nil
}
-func (x *FunctionCallContent) GetThoughtSignature() []byte {
+func (x *ToolCallContent) GetFunctionCall() *FunctionCallContent {
if x != nil {
- return x.ThoughtSignature
+ if x, ok := x.Type.(*ToolCallContent_FunctionCall); ok {
+ return x.FunctionCall
+ }
}
return nil
}
-type FunctionResponseContent struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- Response *structpb.Struct `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"`
- Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`
+type isToolCallContent_Type interface {
+ isToolCallContent_Type()
+}
+
+type ToolCallContent_FunctionCall struct {
+ FunctionCall *FunctionCallContent `protobuf:"bytes,2,opt,name=function_call,json=functionCall,proto3,oneof"`
+}
+
+func (*ToolCallContent_FunctionCall) isToolCallContent_Type() {}
+
+type ToolResultContent struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ CallId string `protobuf:"bytes,8,opt,name=call_id,json=callId,proto3" json:"call_id,omitempty"` // ID to match the ID from the function call block.
+ Signature []byte `protobuf:"bytes,9,opt,name=signature,proto3" json:"signature,omitempty"` // A signature hash for backend validation.
+ // Types that are valid to be assigned to Type:
+ //
+ // *ToolResultContent_FunctionResult
+ Type isToolResultContent_Type `protobuf_oneof:"type"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
-func (x *FunctionResponseContent) Reset() {
- *x = FunctionResponseContent{}
+func (x *ToolResultContent) Reset() {
+ *x = ToolResultContent{}
mi := &file_proto_content_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
-func (x *FunctionResponseContent) String() string {
+func (x *ToolResultContent) String() string {
return protoimpl.X.MessageStringOf(x)
}
-func (*FunctionResponseContent) ProtoMessage() {}
+func (*ToolResultContent) ProtoMessage() {}
-func (x *FunctionResponseContent) ProtoReflect() protoreflect.Message {
+func (x *ToolResultContent) ProtoReflect() protoreflect.Message {
mi := &file_proto_content_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -369,49 +386,194 @@ func (x *FunctionResponseContent) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
-// Deprecated: Use FunctionResponseContent.ProtoReflect.Descriptor instead.
-func (*FunctionResponseContent) Descriptor() ([]byte, []int) {
+// Deprecated: Use ToolResultContent.ProtoReflect.Descriptor instead.
+func (*ToolResultContent) Descriptor() ([]byte, []int) {
return file_proto_content_proto_rawDescGZIP(), []int{5}
}
-func (x *FunctionResponseContent) GetName() string {
+func (x *ToolResultContent) GetCallId() string {
+ if x != nil {
+ return x.CallId
+ }
+ return ""
+}
+
+func (x *ToolResultContent) GetSignature() []byte {
+ if x != nil {
+ return x.Signature
+ }
+ return nil
+}
+
+func (x *ToolResultContent) GetType() isToolResultContent_Type {
+ if x != nil {
+ return x.Type
+ }
+ return nil
+}
+
+func (x *ToolResultContent) GetFunctionResult() *FunctionResultContent {
+ if x != nil {
+ if x, ok := x.Type.(*ToolResultContent_FunctionResult); ok {
+ return x.FunctionResult
+ }
+ }
+ return nil
+}
+
+type isToolResultContent_Type interface {
+ isToolResultContent_Type()
+}
+
+type ToolResultContent_FunctionResult struct {
+ FunctionResult *FunctionResultContent `protobuf:"bytes,2,opt,name=function_result,json=functionResult,proto3,oneof"`
+}
+
+func (*ToolResultContent_FunctionResult) isToolResultContent_Type() {}
+
+type FunctionCallContent struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
+ Arguments *structpb.Struct `protobuf:"bytes,4,opt,name=arguments,proto3" json:"arguments,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *FunctionCallContent) Reset() {
+ *x = FunctionCallContent{}
+ mi := &file_proto_content_proto_msgTypes[6]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *FunctionCallContent) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*FunctionCallContent) ProtoMessage() {}
+
+func (x *FunctionCallContent) ProtoReflect() protoreflect.Message {
+ mi := &file_proto_content_proto_msgTypes[6]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use FunctionCallContent.ProtoReflect.Descriptor instead.
+func (*FunctionCallContent) Descriptor() ([]byte, []int) {
+ return file_proto_content_proto_rawDescGZIP(), []int{6}
+}
+
+func (x *FunctionCallContent) GetName() string {
if x != nil {
return x.Name
}
return ""
}
-func (x *FunctionResponseContent) GetResponse() *structpb.Struct {
+func (x *FunctionCallContent) GetArguments() *structpb.Struct {
if x != nil {
- return x.Response
+ return x.Arguments
}
return nil
}
-func (x *FunctionResponseContent) GetId() string {
+type FunctionResultContent struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Name string `protobuf:"bytes,8,opt,name=name,proto3" json:"name,omitempty"`
+ // Types that are valid to be assigned to Result:
+ //
+ // *FunctionResultContent_Response
+ Result isFunctionResultContent_Result `protobuf_oneof:"result"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *FunctionResultContent) Reset() {
+ *x = FunctionResultContent{}
+ mi := &file_proto_content_proto_msgTypes[7]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *FunctionResultContent) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*FunctionResultContent) ProtoMessage() {}
+
+func (x *FunctionResultContent) ProtoReflect() protoreflect.Message {
+ mi := &file_proto_content_proto_msgTypes[7]
if x != nil {
- return x.Id
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use FunctionResultContent.ProtoReflect.Descriptor instead.
+func (*FunctionResultContent) Descriptor() ([]byte, []int) {
+ return file_proto_content_proto_rawDescGZIP(), []int{7}
+}
+
+func (x *FunctionResultContent) GetName() string {
+ if x != nil {
+ return x.Name
}
return ""
}
+func (x *FunctionResultContent) GetResult() isFunctionResultContent_Result {
+ if x != nil {
+ return x.Result
+ }
+ return nil
+}
+
+func (x *FunctionResultContent) GetResponse() *structpb.Struct {
+ if x != nil {
+ if x, ok := x.Result.(*FunctionResultContent_Response); ok {
+ return x.Response
+ }
+ }
+ return nil
+}
+
+type isFunctionResultContent_Result interface {
+ isFunctionResultContent_Result()
+}
+
+type FunctionResultContent_Response struct {
+ Response *structpb.Struct `protobuf:"bytes,3,opt,name=response,proto3,oneof"`
+}
+
+func (*FunctionResultContent_Response) isFunctionResultContent_Result() {}
+
// Content represents a content input or output.
type Content struct {
state protoimpl.MessageState `protogen:"open.v1"`
- // Types that are valid to be assigned to Content:
+ // Types that are valid to be assigned to Type:
//
// *Content_Text
// *Content_Confirmation
- // *Content_FunctionCall
- // *Content_FunctionResponse
- Content isContent_Content `protobuf_oneof:"content"`
+ // *Content_ToolCall
+ // *Content_ToolResult
+ Type isContent_Type `protobuf_oneof:"type"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Content) Reset() {
*x = Content{}
- mi := &file_proto_content_proto_msgTypes[6]
+ mi := &file_proto_content_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -423,7 +585,7 @@ func (x *Content) String() string {
func (*Content) ProtoMessage() {}
func (x *Content) ProtoReflect() protoreflect.Message {
- mi := &file_proto_content_proto_msgTypes[6]
+ mi := &file_proto_content_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -436,19 +598,19 @@ func (x *Content) ProtoReflect() protoreflect.Message {
// Deprecated: Use Content.ProtoReflect.Descriptor instead.
func (*Content) Descriptor() ([]byte, []int) {
- return file_proto_content_proto_rawDescGZIP(), []int{6}
+ return file_proto_content_proto_rawDescGZIP(), []int{8}
}
-func (x *Content) GetContent() isContent_Content {
+func (x *Content) GetType() isContent_Type {
if x != nil {
- return x.Content
+ return x.Type
}
return nil
}
func (x *Content) GetText() *TextContent {
if x != nil {
- if x, ok := x.Content.(*Content_Text); ok {
+ if x, ok := x.Type.(*Content_Text); ok {
return x.Text
}
}
@@ -457,33 +619,33 @@ func (x *Content) GetText() *TextContent {
func (x *Content) GetConfirmation() *ConfirmationContent {
if x != nil {
- if x, ok := x.Content.(*Content_Confirmation); ok {
+ if x, ok := x.Type.(*Content_Confirmation); ok {
return x.Confirmation
}
}
return nil
}
-func (x *Content) GetFunctionCall() *FunctionCallContent {
+func (x *Content) GetToolCall() *ToolCallContent {
if x != nil {
- if x, ok := x.Content.(*Content_FunctionCall); ok {
- return x.FunctionCall
+ if x, ok := x.Type.(*Content_ToolCall); ok {
+ return x.ToolCall
}
}
return nil
}
-func (x *Content) GetFunctionResponse() *FunctionResponseContent {
+func (x *Content) GetToolResult() *ToolResultContent {
if x != nil {
- if x, ok := x.Content.(*Content_FunctionResponse); ok {
- return x.FunctionResponse
+ if x, ok := x.Type.(*Content_ToolResult); ok {
+ return x.ToolResult
}
}
return nil
}
-type isContent_Content interface {
- isContent_Content()
+type isContent_Type interface {
+ isContent_Type()
}
type Content_Text struct {
@@ -491,24 +653,24 @@ type Content_Text struct {
}
type Content_Confirmation struct {
- Confirmation *ConfirmationContent `protobuf:"bytes,26,opt,name=confirmation,proto3,oneof"`
+ Confirmation *ConfirmationContent `protobuf:"bytes,26,opt,name=confirmation,proto3,oneof"` // TODO(jbd): Remove out of the Content.
}
-type Content_FunctionCall struct {
- FunctionCall *FunctionCallContent `protobuf:"bytes,27,opt,name=function_call,json=functionCall,proto3,oneof"`
+type Content_ToolCall struct {
+ ToolCall *ToolCallContent `protobuf:"bytes,24,opt,name=tool_call,json=toolCall,proto3,oneof"`
}
-type Content_FunctionResponse struct {
- FunctionResponse *FunctionResponseContent `protobuf:"bytes,28,opt,name=function_response,json=functionResponse,proto3,oneof"`
+type Content_ToolResult struct {
+ ToolResult *ToolResultContent `protobuf:"bytes,25,opt,name=tool_result,json=toolResult,proto3,oneof"`
}
-func (*Content_Text) isContent_Content() {}
+func (*Content_Text) isContent_Type() {}
-func (*Content_Confirmation) isContent_Content() {}
+func (*Content_Confirmation) isContent_Type() {}
-func (*Content_FunctionCall) isContent_Content() {}
+func (*Content_ToolCall) isContent_Type() {}
-func (*Content_FunctionResponse) isContent_Content() {}
+func (*Content_ToolResult) isContent_Type() {}
var File_proto_content_proto protoreflect.FileDescriptor
@@ -527,24 +689,33 @@ const file_proto_content_proto_rawDesc = "" +
"\bapproval\x18\x05 \x01(\v2\x17.proto.ApprovalDecisionH\x00R\bapproval\x122\n" +
"\adecline\x18\x06 \x01(\v2\x16.proto.DeclineDecisionH\x00R\adeclineB\n" +
"\n" +
- "\bdecisionJ\x04\b\x01\x10\x02J\x04\b\x02\x10\x03R\x04type\"\x93\x01\n" +
+ "\bdecisionJ\x04\b\x01\x10\x02J\x04\b\x02\x10\x03R\x04type\"\x8a\x01\n" +
+ "\x0fToolCallContent\x12\x0e\n" +
+ "\x02id\x18\x01 \x01(\tR\x02id\x12\x1c\n" +
+ "\tsignature\x18\t \x01(\fR\tsignature\x12A\n" +
+ "\rfunction_call\x18\x02 \x01(\v2\x1a.proto.FunctionCallContentH\x00R\ffunctionCallB\x06\n" +
+ "\x04type\"\xa1\x01\n" +
+ "\x11ToolResultContent\x12\x17\n" +
+ "\acall_id\x18\b \x01(\tR\x06callId\x12\x1c\n" +
+ "\tsignature\x18\t \x01(\fR\tsignature\x12G\n" +
+ "\x0ffunction_result\x18\x02 \x01(\v2\x1c.proto.FunctionResultContentH\x00R\x0efunctionResultB\x06\n" +
+ "\x04typeJ\x04\b\x01\x10\x02\"l\n" +
"\x13FunctionCallContent\x12\x12\n" +
- "\x04name\x18\x01 \x01(\tR\x04name\x12+\n" +
- "\x04args\x18\x02 \x01(\v2\x17.google.protobuf.StructR\x04args\x12\x0e\n" +
- "\x02id\x18\x03 \x01(\tR\x02id\x12+\n" +
- "\x11thought_signature\x18\x04 \x01(\fR\x10thoughtSignature\"r\n" +
- "\x17FunctionResponseContent\x12\x12\n" +
- "\x04name\x18\x01 \x01(\tR\x04name\x123\n" +
- "\bresponse\x18\x02 \x01(\v2\x17.google.protobuf.StructR\bresponse\x12\x0e\n" +
- "\x02id\x18\x03 \x01(\tR\x02id\"\xa4\x02\n" +
+ "\x04name\x18\x03 \x01(\tR\x04name\x125\n" +
+ "\targuments\x18\x04 \x01(\v2\x17.google.protobuf.StructR\targumentsJ\x04\b\x01\x10\x02J\x04\b\x02\x10\x03\"~\n" +
+ "\x15FunctionResultContent\x12\x12\n" +
+ "\x04name\x18\b \x01(\tR\x04name\x125\n" +
+ "\bresponse\x18\x03 \x01(\v2\x17.google.protobuf.StructH\x00R\bresponseB\b\n" +
+ "\x06resultJ\x04\b\x01\x10\x02J\x04\b\x04\x10\x05R\x04type\"\x83\x02\n" +
"\aContent\x12(\n" +
"\x04text\x18\n" +
" \x01(\v2\x12.proto.TextContentH\x00R\x04text\x12@\n" +
- "\fconfirmation\x18\x1a \x01(\v2\x1a.proto.ConfirmationContentH\x00R\fconfirmation\x12A\n" +
- "\rfunction_call\x18\x1b \x01(\v2\x1a.proto.FunctionCallContentH\x00R\ffunctionCall\x12M\n" +
- "\x11function_response\x18\x1c \x01(\v2\x1e.proto.FunctionResponseContentH\x00R\x10functionResponseB\t\n" +
- "\acontentJ\x04\b\x01\x10\x05J\x04\b\x06\x10\n" +
- "J\x04\b\v\x10\x1aB\x1cZ\x1agithub.com/google/ax/protob\x06proto3"
+ "\fconfirmation\x18\x1a \x01(\v2\x1a.proto.ConfirmationContentH\x00R\fconfirmation\x125\n" +
+ "\ttool_call\x18\x18 \x01(\v2\x16.proto.ToolCallContentH\x00R\btoolCall\x12;\n" +
+ "\vtool_result\x18\x19 \x01(\v2\x18.proto.ToolResultContentH\x00R\n" +
+ "toolResultB\x06\n" +
+ "\x04typeJ\x04\b\x01\x10\x05J\x04\b\x06\x10\n" +
+ "J\x04\b\v\x10\x18B\x1cZ\x1agithub.com/google/ax/protob\x06proto3"
var (
file_proto_content_proto_rawDescOnce sync.Once
@@ -558,31 +729,35 @@ func file_proto_content_proto_rawDescGZIP() []byte {
return file_proto_content_proto_rawDescData
}
-var file_proto_content_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
+var file_proto_content_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_proto_content_proto_goTypes = []any{
- (*TextContent)(nil), // 0: proto.TextContent
- (*ApprovalDecision)(nil), // 1: proto.ApprovalDecision
- (*DeclineDecision)(nil), // 2: proto.DeclineDecision
- (*ConfirmationContent)(nil), // 3: proto.ConfirmationContent
- (*FunctionCallContent)(nil), // 4: proto.FunctionCallContent
- (*FunctionResponseContent)(nil), // 5: proto.FunctionResponseContent
- (*Content)(nil), // 6: proto.Content
- (*structpb.Struct)(nil), // 7: google.protobuf.Struct
+ (*TextContent)(nil), // 0: proto.TextContent
+ (*ApprovalDecision)(nil), // 1: proto.ApprovalDecision
+ (*DeclineDecision)(nil), // 2: proto.DeclineDecision
+ (*ConfirmationContent)(nil), // 3: proto.ConfirmationContent
+ (*ToolCallContent)(nil), // 4: proto.ToolCallContent
+ (*ToolResultContent)(nil), // 5: proto.ToolResultContent
+ (*FunctionCallContent)(nil), // 6: proto.FunctionCallContent
+ (*FunctionResultContent)(nil), // 7: proto.FunctionResultContent
+ (*Content)(nil), // 8: proto.Content
+ (*structpb.Struct)(nil), // 9: google.protobuf.Struct
}
var file_proto_content_proto_depIdxs = []int32{
- 1, // 0: proto.ConfirmationContent.approval:type_name -> proto.ApprovalDecision
- 2, // 1: proto.ConfirmationContent.decline:type_name -> proto.DeclineDecision
- 7, // 2: proto.FunctionCallContent.args:type_name -> google.protobuf.Struct
- 7, // 3: proto.FunctionResponseContent.response:type_name -> google.protobuf.Struct
- 0, // 4: proto.Content.text:type_name -> proto.TextContent
- 3, // 5: proto.Content.confirmation:type_name -> proto.ConfirmationContent
- 4, // 6: proto.Content.function_call:type_name -> proto.FunctionCallContent
- 5, // 7: proto.Content.function_response:type_name -> proto.FunctionResponseContent
- 8, // [8:8] is the sub-list for method output_type
- 8, // [8:8] is the sub-list for method input_type
- 8, // [8:8] is the sub-list for extension type_name
- 8, // [8:8] is the sub-list for extension extendee
- 0, // [0:8] is the sub-list for field type_name
+ 1, // 0: proto.ConfirmationContent.approval:type_name -> proto.ApprovalDecision
+ 2, // 1: proto.ConfirmationContent.decline:type_name -> proto.DeclineDecision
+ 6, // 2: proto.ToolCallContent.function_call:type_name -> proto.FunctionCallContent
+ 7, // 3: proto.ToolResultContent.function_result:type_name -> proto.FunctionResultContent
+ 9, // 4: proto.FunctionCallContent.arguments:type_name -> google.protobuf.Struct
+ 9, // 5: proto.FunctionResultContent.response:type_name -> google.protobuf.Struct
+ 0, // 6: proto.Content.text:type_name -> proto.TextContent
+ 3, // 7: proto.Content.confirmation:type_name -> proto.ConfirmationContent
+ 4, // 8: proto.Content.tool_call:type_name -> proto.ToolCallContent
+ 5, // 9: proto.Content.tool_result:type_name -> proto.ToolResultContent
+ 10, // [10:10] is the sub-list for method output_type
+ 10, // [10:10] is the sub-list for method input_type
+ 10, // [10:10] is the sub-list for extension type_name
+ 10, // [10:10] is the sub-list for extension extendee
+ 0, // [0:10] is the sub-list for field type_name
}
func init() { file_proto_content_proto_init() }
@@ -594,11 +769,20 @@ func file_proto_content_proto_init() {
(*ConfirmationContent_Approval)(nil),
(*ConfirmationContent_Decline)(nil),
}
- file_proto_content_proto_msgTypes[6].OneofWrappers = []any{
+ file_proto_content_proto_msgTypes[4].OneofWrappers = []any{
+ (*ToolCallContent_FunctionCall)(nil),
+ }
+ file_proto_content_proto_msgTypes[5].OneofWrappers = []any{
+ (*ToolResultContent_FunctionResult)(nil),
+ }
+ file_proto_content_proto_msgTypes[7].OneofWrappers = []any{
+ (*FunctionResultContent_Response)(nil),
+ }
+ file_proto_content_proto_msgTypes[8].OneofWrappers = []any{
(*Content_Text)(nil),
(*Content_Confirmation)(nil),
- (*Content_FunctionCall)(nil),
- (*Content_FunctionResponse)(nil),
+ (*Content_ToolCall)(nil),
+ (*Content_ToolResult)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -606,7 +790,7 @@ func file_proto_content_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_content_proto_rawDesc), len(file_proto_content_proto_rawDesc)),
NumEnums: 0,
- NumMessages: 7,
+ NumMessages: 9,
NumExtensions: 0,
NumServices: 0,
},
diff --git a/proto/content.proto b/proto/content.proto
index fd33d1a..467475d 100644
--- a/proto/content.proto
+++ b/proto/content.proto
@@ -48,27 +48,50 @@ message ConfirmationContent {
}
}
+message ToolCallContent {
+ string id = 1; // A unique ID for this specific tool call.
+ bytes signature = 9; // A signature hash for backend validation.
+ oneof type {
+ FunctionCallContent function_call = 2;
+ }
+}
+
+message ToolResultContent {
+ reserved 1;
+
+ string call_id = 8; // ID to match the ID from the function call block.
+ bytes signature = 9; // A signature hash for backend validation.
+
+ oneof type {
+ FunctionResultContent function_result = 2;
+ }
+}
+
message FunctionCallContent {
- string name = 1;
- google.protobuf.Struct args = 2;
- string id = 3;
- bytes thought_signature = 4;
+ reserved 1, 2;
+
+ string name = 3;
+ google.protobuf.Struct arguments = 4;
}
-message FunctionResponseContent {
- string name = 1;
- google.protobuf.Struct response = 2;
- string id = 3;
+message FunctionResultContent {
+ reserved 1, 4;
+ reserved "type";
+
+ string name = 8;
+ oneof result {
+ google.protobuf.Struct response = 3;
+ }
}
// Content represents a content input or output.
message Content {
- reserved 1 to 4, 6 to 9, 11 to 25;
+ reserved 1 to 4, 6 to 9, 11 to 23;
- oneof content {
+ oneof type {
TextContent text = 10;
- ConfirmationContent confirmation = 26;
- FunctionCallContent function_call = 27;
- FunctionResponseContent function_response = 28;
+ ConfirmationContent confirmation = 26; // TODO(jbd): Remove out of the Content.
+ ToolCallContent tool_call = 24;
+ ToolResultContent tool_result = 25;
}
}