Skip to content

armgit / ax

Public Imported from GitHub
0

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

Go

Introduce Message to remove "role" from Content (#145)

Jaana Dogan38d14a1afa34
diff --git a/cmd/ax/exec.go b/cmd/ax/exec.go
index 5ff5560..f69ef67 100644
--- a/cmd/ax/exec.go
+++ b/cmd/ax/exec.go
@@ -96,7 +96,7 @@ func execLoop(ctx context.Context, id string, agentID string, input string) erro
d := internal.NewDisplay(id)
d.DisplayHeader()
- var history []*proto.Content
+ var history []*proto.Message
if !execResume {
input, quit, err := promptUser(d, input)
if err != nil {
@@ -105,12 +105,14 @@ func execLoop(ctx context.Context, id string, agentID string, input string) erro
if quit {
return nil
}
- history = []*proto.Content{
+ history = []*proto.Message{
{
Role: "user",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: input,
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: input,
+ },
},
},
},
@@ -130,27 +132,31 @@ func execLoop(ctx context.Context, id string, agentID string, input string) erro
if err != nil {
return err
}
- var decision []*proto.Content
+ var decision []*proto.Message
if approved {
- decision = []*proto.Content{{
+ decision = []*proto.Message{{
Role: "user",
- Content: &proto.Content_Confirmation{
- Confirmation: &proto.ConfirmationContent{
- Id: conf.Id,
- Decision: &proto.ConfirmationContent_Approval{
- Approval: &proto.ApprovalDecision{Approved: true},
+ Content: &proto.Content{
+ Content: &proto.Content_Confirmation{
+ Confirmation: &proto.ConfirmationContent{
+ Id: conf.Id,
+ Decision: &proto.ConfirmationContent_Approval{
+ Approval: &proto.ApprovalDecision{Approved: true},
+ },
},
},
},
}}
} else {
- decision = []*proto.Content{{
+ decision = []*proto.Message{{
Role: "user",
- Content: &proto.Content_Confirmation{
- Confirmation: &proto.ConfirmationContent{
- Id: conf.Id,
- Decision: &proto.ConfirmationContent_Decline{
- Decline: &proto.DeclineDecision{Declined: true},
+ Content: &proto.Content{
+ Content: &proto.Content_Confirmation{
+ Confirmation: &proto.ConfirmationContent{
+ Id: conf.Id,
+ Decision: &proto.ConfirmationContent_Decline{
+ Decline: &proto.DeclineDecision{Declined: true},
+ },
},
},
},
@@ -189,18 +195,20 @@ func execLoop(ctx context.Context, id string, agentID string, input string) erro
if quit {
return nil
}
- history = append(history, &proto.Content{
+ history = append(history, &proto.Message{
Role: "user",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: input,
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: input,
+ },
},
},
})
}
}
-func runAutoExec(ctx context.Context, d *internal.Display, id string, agentID string, inputs []*proto.Content) (*proto.ConfirmationContent, []*proto.Content, error) {
+func runAutoExec(ctx context.Context, d *internal.Display, id string, agentID string, inputs []*proto.Message) (*proto.ConfirmationContent, []*proto.Message, error) {
fn := runExecHeadless
if execServerAddr != "" {
fn = runExecServer
@@ -208,7 +216,7 @@ func runAutoExec(ctx context.Context, d *internal.Display, id string, agentID st
return fn(ctx, d, id, agentID, inputs)
}
-func runExecHeadless(ctx context.Context, d *internal.Display, id string, agentID string, inputs []*proto.Content) (*proto.ConfirmationContent, []*proto.Content, error) {
+func runExecHeadless(ctx context.Context, d *internal.Display, id string, agentID string, inputs []*proto.Message) (*proto.ConfirmationContent, []*proto.Message, error) {
if execController == nil {
cfg, err := config.LoadFromFile(execConfigFile)
if err != nil {
@@ -223,20 +231,20 @@ func runExecHeadless(ctx context.Context, d *internal.Display, id string, agentI
}
var checkpoint string
- var outputs []*proto.Content
+ var outputs []*proto.Message
var confirmation *proto.ConfirmationContent
outputHandler := agent.OutputHandler(func(resp *proto.AgentOutputs) error {
if resp.CheckpointId != "" {
checkpoint = resp.CheckpointId
}
- for _, c := range resp.Contents {
- if conf := c.GetConfirmation(); conf != nil {
+ for _, m := range resp.Messages {
+ if conf := m.GetContent().GetConfirmation(); conf != nil {
confirmation = conf
}
}
- outputs = append(outputs, resp.Contents...)
- displayContents(d, resp.Contents)
+ outputs = append(outputs, resp.Messages...)
+ displayContents(d, resp.Messages)
return nil
})
if err := execController.Exec(ctx, &proto.AgentMessage{
@@ -244,7 +252,7 @@ func runExecHeadless(ctx context.Context, d *internal.Display, id string, agentI
Msg: &proto.AgentMessage_Start{
Start: &proto.AgentStart{
AgentId: agentID,
- Contents: inputs,
+ Messages: inputs,
},
},
}, outputHandler); err != nil {
@@ -257,7 +265,7 @@ func runExecHeadless(ctx context.Context, d *internal.Display, id string, agentI
return confirmation, outputs, nil
}
-func runExecServer(ctx context.Context, d *internal.Display, id string, agentID string, inputs []*proto.Content) (*proto.ConfirmationContent, []*proto.Content, error) {
+func runExecServer(ctx context.Context, d *internal.Display, id string, agentID string, inputs []*proto.Message) (*proto.ConfirmationContent, []*proto.Message, error) {
conn, err := connect(execServerAddr)
if err != nil {
return nil, nil, err
@@ -275,7 +283,7 @@ func runExecServer(ctx context.Context, d *internal.Display, id string, agentID
}
var checkpoint string
- var outputs []*proto.Content
+ var outputs []*proto.Message
var confirmation *proto.ConfirmationContent
for {
resp, err := stream.Recv()
@@ -286,8 +294,8 @@ func runExecServer(ctx context.Context, d *internal.Display, id string, agentID
return nil, nil, fmt.Errorf("error receiving response: %w", err)
}
if resp.Outputs != nil {
- for _, c := range resp.Outputs {
- if conf := c.GetConfirmation(); conf != nil {
+ for _, m := range resp.Outputs {
+ if conf := m.GetContent().GetConfirmation(); conf != nil {
confirmation = conf
}
}
@@ -301,9 +309,13 @@ func runExecServer(ctx context.Context, d *internal.Display, id string, agentID
return confirmation, outputs, nil
}
-func displayContents(d *internal.Display, contents []*proto.Content) {
+func displayContents(d *internal.Display, contents []*proto.Message) {
for _, output := range contents {
- switch o := output.Content.(type) {
+ content := output.GetContent()
+ if content == nil {
+ continue
+ }
+ switch o := content.Content.(type) {
case *proto.Content_Text:
d.DisplayOutput(o.Text.Text)
case *proto.Content_Confirmation:
@@ -322,19 +334,20 @@ func displayContents(d *internal.Display, contents []*proto.Content) {
}
}
-func resetHistory(history []*proto.Content) []*proto.Content {
- var out []*proto.Content
- for _, c := range history {
- if c.GetFunctionCall() != nil {
+func resetHistory(history []*proto.Message) []*proto.Message {
+ var out []*proto.Message
+ for _, m := range history {
+ content := m.GetContent()
+ if content.GetFunctionCall() != nil {
continue
}
- if c.GetFunctionResponse() != nil {
+ if content.GetFunctionResponse() != nil {
continue
}
- if c.GetConfirmation() != nil {
+ if content.GetConfirmation() != nil {
continue
}
- out = append(out, c)
+ out = append(out, m)
}
return out
}
diff --git a/cmd/ax/trace.go b/cmd/ax/trace.go
index 6991483..a67be55 100644
--- a/cmd/ax/trace.go
+++ b/cmd/ax/trace.go
@@ -184,13 +184,17 @@ func buildExecTraces(rootExecID string, events []*proto.ExecutionEvent) []ExecTr
return execs
}
-func extractContents(protoContents []*proto.Content) []Content {
+func extractMsgs(protoContents []*proto.Message) []Content {
var results []Content
for _, c := range protoContents {
content := Content{Role: c.Role}
- if textC := c.GetText(); textC != nil {
+ msgContent := c.GetContent()
+ if msgContent == nil {
+ continue
+ }
+ if textC := msgContent.GetText(); textC != nil {
content.Text = &Text{Text: textC.Text}
- } else if conf := c.GetConfirmation(); conf != nil {
+ } else if conf := msgContent.GetConfirmation(); conf != nil {
content.Confirmation = &Confirmation{
ID: conf.Id,
Question: conf.Question,
@@ -216,8 +220,8 @@ func extractExecutionEvent(execID string, protoEv *proto.ExecutionEvent) Executi
}
ev.State = fmt.Sprint(protoEv.State)
- ev.Outputs = extractContents(protoEv.Outputs)
- ev.Inputs = extractContents(protoEv.Inputs)
+ ev.Outputs = extractMsgs(protoEv.Outputs)
+ ev.Inputs = extractMsgs(protoEv.Inputs)
return ev
}
diff --git a/examples/k8s_sandbox_agent/main.go b/examples/k8s_sandbox_agent/main.go
index 892f774..e5861d9 100644
--- a/examples/k8s_sandbox_agent/main.go
+++ b/examples/k8s_sandbox_agent/main.go
@@ -49,14 +49,15 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, pro
return err
}
- var outputs []*proto.Content
+ var outputs []*proto.Message
start := req.GetStart()
- if start != nil && len(start.Contents) > 0 {
+ if start != nil && len(start.Messages) > 0 {
// Find the most recent message from the "user" in the history
var targetText string
- for i := len(start.Contents) - 1; i >= 0; i-- {
- if text := start.Contents[i].GetText(); text != nil && start.Contents[i].Role == "user" {
- targetText = text.Text
+ for i := len(start.Messages) - 1; i >= 0; i-- {
+ msg := start.Messages[i]
+ if textContent := msg.GetContent().GetText(); textContent != nil && msg.Role == "user" {
+ targetText = textContent.Text
break
}
}
@@ -68,19 +69,23 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, pro
log.Printf("📥 Processed resolved text: %q", targetText)
log.Printf("📤 Sending response: %q", upper)
- outputs = append(outputs, &proto.Content{
+ outputs = append(outputs, &proto.Message{
Role: "agent",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "Hey, I'm your sandbox agent.\n",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "Hey, I'm your sandbox agent.\n",
+ },
},
},
})
- outputs = append(outputs, &proto.Content{
+ outputs = append(outputs, &proto.Message{
Role: "agent",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: fmt.Sprintf("here is your upper case text: %s", upper),
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: fmt.Sprintf("here is your upper case text: %s", upper),
+ },
},
},
})
@@ -93,7 +98,7 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, pro
ExecId: req.ExecId,
Msg: &proto.AgentMessage_Outputs{
Outputs: &proto.AgentOutputs{
- Contents: outputs,
+ Messages: outputs,
},
},
}); err != nil {
diff --git a/examples/k8s_sandbox_agent/main_test.go b/examples/k8s_sandbox_agent/main_test.go
index 6b9832f..4307ba5 100644
--- a/examples/k8s_sandbox_agent/main_test.go
+++ b/examples/k8s_sandbox_agent/main_test.go
@@ -24,30 +24,38 @@ import (
func TestExtractLatestPayload(t *testing.T) {
// Let's create a simulated history payload
- history := []*proto.Content{
+ history := []*proto.Message{
{
Role: "user",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{Text: "old user prompt"},
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{Text: "old user prompt"},
+ },
},
},
{
Role: "agent",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{Text: "old agent response"},
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{Text: "old agent response"},
+ },
},
},
{
Role: "user",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{Text: "find this text plz plz plz"},
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{Text: "find this text plz plz plz"},
+ },
},
},
{
- Role: "agent", // System might wrap it in something like this during delegation
- Content: &proto.Content_FunctionCall{
- FunctionCall: &proto.FunctionCallContent{
- Name: "uppercase-agent",
+ Role: "agent",
+ Content: &proto.Content{
+ Content: &proto.Content_FunctionCall{
+ FunctionCall: &proto.FunctionCallContent{
+ Name: "uppercase-agent",
+ },
},
},
},
@@ -56,10 +64,11 @@ func TestExtractLatestPayload(t *testing.T) {
// 1. Emulate the agent logic exactly!
var targetText string
for i := len(history) - 1; i >= 0; i-- {
- // As per our fix, we just grab the last raw text we can find from a user
- if text := history[i].GetText(); text != nil && history[i].Role == "user" {
- targetText = text.Text
- break
+ if content := history[i].GetContent(); content != nil {
+ if text := content.GetText(); text != nil && history[i].Role == "user" {
+ targetText = text.Text
+ break
+ }
}
}
@@ -69,25 +78,29 @@ func TestExtractLatestPayload(t *testing.T) {
// 2. Format output
upper := strings.ToUpper(targetText)
- var outputs []*proto.Content
- outputs = append(outputs, &proto.Content{
+ var outputs []*proto.Message
+ outputs = append(outputs, &proto.Message{
Role: "agent",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "Hey, I'm your sandbox agent.\n",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "Hey, I'm your sandbox agent.\n",
+ },
},
},
})
- outputs = append(outputs, &proto.Content{
+ outputs = append(outputs, &proto.Message{
Role: "agent",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: fmt.Sprintf("here is your upper case text: %s", upper),
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: fmt.Sprintf("here is your upper case text: %s", upper),
+ },
},
},
})
- if len(outputs) != 2 || !strings.Contains(outputs[1].GetText().Text, strings.ToUpper("find this text plz plz plz")) {
+ if len(outputs) != 2 || !strings.Contains(outputs[1].GetContent().GetText().Text, strings.ToUpper("find this text plz plz plz")) {
t.Errorf("Outputs failed! Got: %v", outputs)
}
}
diff --git a/examples/remote_agent/main.go b/examples/remote_agent/main.go
index d3f2cec..29e8d51 100644
--- a/examples/remote_agent/main.go
+++ b/examples/remote_agent/main.go
@@ -54,25 +54,31 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, pro
continue // optionally wait for start
}
- var contents []*proto.Content
- for _, input := range startMsg.Contents {
- textContent := input.GetText()
+ var messages []*proto.Message
+ for _, input := range startMsg.Messages {
+ textContent := input.GetContent().GetText()
if textContent == nil {
continue
}
- contents = append(contents, input)
+ messages = append(messages, input)
}
- if len(contents) == 0 {
+ if len(messages) == 0 {
return errors.New("no text inputs, cannot uppercase")
}
// We don't need to uppercase the whole history.
// Only uppercase the last text message.
- last := contents[len(contents)-1]
- last.Role = "assistant"
- last.Content = &proto.Content_Text{
- Text: &proto.TextContent{
- Text: strings.ToLower(last.GetText().Text),
+ lastMsg := messages[len(messages)-1]
+ responseText := strings.ToLower(lastMsg.GetContent().GetText().Text) // Preserving ToLower as in original code
+
+ responseMsg := &proto.Message{
+ Role: "assistant",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: responseText,
+ },
+ },
},
}
@@ -80,7 +86,7 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, pro
ExecId: incoming.ExecId,
Msg: &proto.AgentMessage_Outputs{
Outputs: &proto.AgentOutputs{
- Contents: []*proto.Content{last},
+ Messages: []*proto.Message{responseMsg},
CheckpointId: uuid.New().String(),
},
},
diff --git a/internal/controller/executor/executor.go b/internal/controller/executor/executor.go
index 27f994b..4886497 100644
--- a/internal/controller/executor/executor.go
+++ b/internal/controller/executor/executor.go
@@ -75,7 +75,7 @@ func (tm *defaultExecutor) exec(
start *proto.AgentStart,
el EventLog,
a agent.Agent,
- history []*proto.Content,
+ history []*proto.Message,
o agent.OutputHandler) error {
child := &defaultExecutor{
id: execID,
@@ -83,16 +83,16 @@ func (tm *defaultExecutor) exec(
registry: tm.registry,
}
- var allOutputs []*proto.Content
+ var allOutputs []*proto.Message
outputBuffer := func(outgoing *proto.AgentOutputs) error {
- allOutputs = append(allOutputs, outgoing.Contents...)
+ allOutputs = append(allOutputs, outgoing.Messages...)
if o != nil {
return o(outgoing)
}
return nil
}
- history = append(history, start.Contents...)
+ history = append(history, start.Messages...)
if len(history) == 0 {
return errors.New("no inputs")
}
@@ -100,7 +100,7 @@ func (tm *defaultExecutor) exec(
return err
}
- start.Contents = history
+ start.Messages = history
if err := a.Connect(ctx, execID, start, child, outputBuffer); err != nil {
_ = logFailed(ctx, el, execID, start) // Attempt to log failure, but prioritize returning the original error.
return err
@@ -114,7 +114,7 @@ func (tm *defaultExecutor) exec(
}
last := allOutputs[len(allOutputs)-1]
- if last.GetConfirmation() == nil || last.GetConfirmation().GetQuestion() == "" {
+ if last.GetContent().GetConfirmation() == nil || last.GetContent().GetConfirmation().GetQuestion() == "" {
// Log completed only if we are not waiting
// for an answer to a confirmation.
return logCompleted(ctx, el, execID, start)
@@ -123,13 +123,13 @@ func (tm *defaultExecutor) exec(
return nil
}
-func history(ctx context.Context, el EventLog, execID string) ([]*proto.Content, proto.State, string, error) {
+func history(ctx context.Context, el EventLog, execID string) ([]*proto.Message, proto.State, string, error) {
events, err := el.Events(ctx, execID)
if err != nil {
return nil, proto.State_STATE_UNSPECIFIED, "", err
}
- var history []*proto.Content
+ var history []*proto.Message
var state proto.State
var agentID string
@@ -145,7 +145,7 @@ func history(ctx context.Context, el EventLog, execID string) ([]*proto.Content,
// presented an event log with dirty entries
// from previous runs.
if event.State == proto.State_STATE_PENDING {
- history = []*proto.Content{}
+ history = []*proto.Message{}
}
history = append(history, event.Inputs...)
history = append(history, event.Outputs...)
@@ -160,7 +160,7 @@ func logPending(ctx context.Context, el EventLog, execID string, start *proto.Ag
Timestamp: timestamppb.Now(),
ExecId: execID,
AgentId: start.AgentId,
- Inputs: start.Contents,
+ Inputs: start.Messages,
State: proto.State_STATE_PENDING,
})
}
@@ -183,7 +183,7 @@ func logCompleted(ctx context.Context, el EventLog, execID string, start *proto.
})
}
-func logOutputs(ctx context.Context, el EventLog, execID string, start *proto.AgentStart, outputs []*proto.Content) error {
+func logOutputs(ctx context.Context, el EventLog, execID string, start *proto.AgentStart, outputs []*proto.Message) error {
return el.Append(ctx, &proto.ExecutionEvent{
Timestamp: timestamppb.Now(),
ExecId: execID,
diff --git a/internal/controller/executor/executor_test.go b/internal/controller/executor/executor_test.go
index 9ca31ad..75bec9a 100644
--- a/internal/controller/executor/executor_test.go
+++ b/internal/controller/executor/executor_test.go
@@ -85,17 +85,17 @@ func Example() {
ctx := context.Background()
registry := map[string]agent.Agent{
- "planner": AgentFunc(func(inputs []*proto.Content, tm agent.Executor, o agent.OutputHandler) {
+ "planner": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
if err := tm.Exec(ctx, "deep-research-task", &proto.AgentStart{
AgentId: "deep-research",
- Contents: inputs,
+ Messages: inputs,
}, o); err != nil {
return
}
if err := tm.Exec(ctx, "pub-med-lookup-task", &proto.AgentStart{
AgentId: "pub-med-index",
- Contents: inputs,
+ Messages: inputs,
}, o); err != nil {
return
}
@@ -105,7 +105,7 @@ func Example() {
tm := DefaultExecutor(memoryEventLog(), registry)
if err := tm.Exec(ctx, "test", &proto.AgentStart{
AgentId: "planner",
- Contents: []*proto.Content{text("user", "Hello, I'd like to research cancer treatment options.")},
+ Messages: []*proto.Message{text("user", "Hello, I'd like to research cancer treatment options.")},
}, nil); err != nil {
log.Fatal(err)
}
@@ -115,24 +115,24 @@ func TestTaskManager(t *testing.T) {
ctx := context.Background()
registry := map[string]agent.Agent{
- "root": AgentFunc(func(inputs []*proto.Content, tm agent.Executor, o agent.OutputHandler) {
+ "root": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
if err := tm.Exec(ctx, "child-task", &proto.AgentStart{
AgentId: "child",
- Contents: inputs,
+ Messages: inputs,
}, o); err != nil {
t.Fatal(err)
}
if o != nil {
o(&proto.AgentOutputs{
- Contents: []*proto.Content{text("assistant", "root done")},
+ Messages: []*proto.Message{text("assistant", "root done")},
})
}
}),
- "child": AgentFunc(func(inputs []*proto.Content, tm agent.Executor, o agent.OutputHandler) {
+ "child": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
time.Sleep(100 * time.Millisecond)
if o != nil {
o(&proto.AgentOutputs{
- Contents: []*proto.Content{text("assistant", "child done")},
+ Messages: []*proto.Message{text("assistant", "child done")},
})
}
}),
@@ -141,7 +141,7 @@ func TestTaskManager(t *testing.T) {
tm := DefaultExecutor(memoryEventLog(), registry)
if err := tm.Exec(ctx, "root-task", &proto.AgentStart{
AgentId: "root",
- Contents: []*proto.Content{text("user", "hello!")},
+ Messages: []*proto.Message{text("user", "hello!")},
}, nil); err != nil {
t.Fatal(err)
}
@@ -152,14 +152,14 @@ func TestFanout(t *testing.T) {
var executions atomic.Int32
registry := map[string]agent.Agent{
- "root": AgentFunc(func(inputs []*proto.Content, tm agent.Executor, o agent.OutputHandler) {
+ "root": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
var g errgroup.Group
for i := 0; i < 50; i++ {
i := i // Capture loop variable.
g.Go(func() error {
return tm.Exec(ctx, fmt.Sprintf("child-%d", i), &proto.AgentStart{
AgentId: "child",
- Contents: inputs,
+ Messages: inputs,
}, nil)
})
}
@@ -168,11 +168,11 @@ func TestFanout(t *testing.T) {
}
if o != nil {
o(&proto.AgentOutputs{
- Contents: []*proto.Content{text("assistant", "root done")},
+ Messages: []*proto.Message{text("assistant", "root done")},
})
}
}),
- "child": AgentFunc(func(inputs []*proto.Content, tm agent.Executor, o agent.OutputHandler) {
+ "child": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
executions.Add(1)
time.Sleep(100 * time.Millisecond)
@@ -182,7 +182,7 @@ func TestFanout(t *testing.T) {
g.Go(func() error {
return tm.Exec(ctx, fmt.Sprintf("child2-%d", i), &proto.AgentStart{
AgentId: "child2",
- Contents: inputs,
+ Messages: inputs,
}, nil)
})
}
@@ -191,16 +191,16 @@ func TestFanout(t *testing.T) {
}
if o != nil {
o(&proto.AgentOutputs{
- Contents: []*proto.Content{text("assistant", "child done")},
+ Messages: []*proto.Message{text("assistant", "child done")},
})
}
}),
- "child2": AgentFunc(func(inputs []*proto.Content, tm agent.Executor, o agent.OutputHandler) {
+ "child2": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
executions.Add(1)
time.Sleep(100 * time.Millisecond)
if o != nil {
o(&proto.AgentOutputs{
- Contents: []*proto.Content{text("assistant", "child2 done")},
+ Messages: []*proto.Message{text("assistant", "child2 done")},
})
}
}),
@@ -209,7 +209,7 @@ func TestFanout(t *testing.T) {
tm := DefaultExecutor(memoryEventLog(), registry)
if err := tm.Exec(ctx, "root-task", &proto.AgentStart{
AgentId: "root",
- Contents: []*proto.Content{text("user", "hello!")},
+ Messages: []*proto.Message{text("user", "hello!")},
}, nil); err != nil {
t.Fatal(err)
}
@@ -228,23 +228,26 @@ func TestConfirmation(t *testing.T) {
confID := "test-conf-id"
var childDone atomic.Bool
registry := map[string]agent.Agent{
- "root": AgentFunc(func(inputs []*proto.Content, tm agent.Executor, o agent.OutputHandler) {
+ "root": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
if err := tm.Exec(ctx, "child-task", &proto.AgentStart{
AgentId: "child",
- Contents: inputs,
+ Messages: inputs,
}, o); err != nil {
t.Fatal(err)
}
}),
- "child": AgentFunc(func(inputs []*proto.Content, tm agent.Executor, o agent.OutputHandler) {
+ "child": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
if runCount == 0 {
runCount++
log.Println("Asking for the question...")
if o != nil {
o(&proto.AgentOutputs{
- Contents: []*proto.Content{{
- Content: &proto.Content_Confirmation{
- Confirmation: &proto.ConfirmationContent{Id: confID, Question: "proceed?"},
+ Messages: []*proto.Message{{
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_Confirmation{
+ Confirmation: &proto.ConfirmationContent{Id: confID, Question: "proceed?"},
+ },
},
}},
})
@@ -253,14 +256,14 @@ func TestConfirmation(t *testing.T) {
}
lastInput := inputs[len(inputs)-1]
- if lastInput.GetConfirmation() == nil || lastInput.GetConfirmation().GetDecision() == nil {
+ if lastInput.GetContent().GetConfirmation() == nil || lastInput.GetContent().GetConfirmation().GetDecision() == nil {
t.Fatal("no decision in the incoming inputs")
}
childDone.Store(true)
if o != nil {
o(&proto.AgentOutputs{
- Contents: []*proto.Content{text("assistant", "child done")},
+ Messages: []*proto.Message{text("assistant", "child done")},
})
}
}),
@@ -271,26 +274,28 @@ func TestConfirmation(t *testing.T) {
// First run: child returns a confirmation request.
if err := tm.Exec(ctx, "root-task", &proto.AgentStart{
AgentId: "root",
- Contents: []*proto.Content{text("user", "hello!")},
+ Messages: []*proto.Message{text("user", "hello!")},
}, nil); err != nil {
t.Fatal(err)
}
// Re-run with the approval decision as new input.
- approval := &proto.Content{
+ approval := &proto.Message{
Role: "user",
- Content: &proto.Content_Confirmation{
- Confirmation: &proto.ConfirmationContent{
- Id: confID,
- Decision: &proto.ConfirmationContent_Approval{
- Approval: &proto.ApprovalDecision{Approved: true},
+ Content: &proto.Content{
+ Content: &proto.Content_Confirmation{
+ Confirmation: &proto.ConfirmationContent{
+ Id: confID,
+ Decision: &proto.ConfirmationContent_Approval{
+ Approval: &proto.ApprovalDecision{Approved: true},
+ },
},
},
},
}
if err := tm.Exec(ctx, "root-task", &proto.AgentStart{
AgentId: "root",
- Contents: []*proto.Content{approval},
+ Messages: []*proto.Message{approval},
}, nil); err != nil {
t.Fatal(err)
}
@@ -305,24 +310,24 @@ func TestResume(t *testing.T) {
eventLog := memoryEventLog()
registry := map[string]agent.Agent{
- "root": AgentFunc(func(inputs []*proto.Content, tm agent.Executor, o agent.OutputHandler) {
+ "root": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
if err := tm.Exec(ctx, "child-task", &proto.AgentStart{
AgentId: "child",
- Contents: inputs,
+ Messages: inputs,
}, nil); err != nil {
t.Fatal(err)
}
if o != nil {
o(&proto.AgentOutputs{
- Contents: []*proto.Content{text("assistant", "root done")},
+ Messages: []*proto.Message{text("assistant", "root done")},
})
}
}),
- "child": AgentFunc(func(inputs []*proto.Content, tm agent.Executor, o agent.OutputHandler) {
+ "child": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
time.Sleep(100 * time.Millisecond)
if o != nil {
o(&proto.AgentOutputs{
- Contents: []*proto.Content{text("assistant", "child done")},
+ Messages: []*proto.Message{text("assistant", "child done")},
})
}
}),
@@ -331,7 +336,7 @@ func TestResume(t *testing.T) {
tm := DefaultExecutor(eventLog, registry)
if err := tm.Exec(ctx, "root-task", &proto.AgentStart{
AgentId: "root",
- Contents: []*proto.Content{text("user", "hello!")},
+ Messages: []*proto.Message{text("user", "hello!")},
}, nil); err != nil {
t.Fatal(err)
}
@@ -342,10 +347,10 @@ func TestResumeAgentIDMismatch(t *testing.T) {
eventLog := memoryEventLog()
registry := map[string]agent.Agent{
- "root": AgentFunc(func(inputs []*proto.Content, tm agent.Executor, o agent.OutputHandler) {
+ "root": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
// Do nothing to leave it in PENDING state
}),
- "other": AgentFunc(func(inputs []*proto.Content, tm agent.Executor, o agent.OutputHandler) {
+ "other": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
}),
}
@@ -354,7 +359,7 @@ func TestResumeAgentIDMismatch(t *testing.T) {
// First run: starts as "root"
if err := tm.Exec(ctx, "task1", &proto.AgentStart{
AgentId: "root",
- Contents: []*proto.Content{text("user", "hello!")},
+ Messages: []*proto.Message{text("user", "hello!")},
}, nil); err != nil {
t.Fatal(err)
}
@@ -362,7 +367,7 @@ func TestResumeAgentIDMismatch(t *testing.T) {
// Second run: attempts to resume as "other" for same execID "task1"
err := tm.Exec(ctx, "task1", &proto.AgentStart{
AgentId: "other",
- Contents: []*proto.Content{text("user", "hello again!")},
+ Messages: []*proto.Message{text("user", "hello again!")},
}, nil)
if err == nil {
diff --git a/internal/controller/executor/sqlite_test.go b/internal/controller/executor/sqlite_test.go
index 4c3aa08..9caf271 100644
--- a/internal/controller/executor/sqlite_test.go
+++ b/internal/controller/executor/sqlite_test.go
@@ -39,8 +39,8 @@ func TestSQLiteEventLog_AppendAndEvents(t *testing.T) {
ExecId: "task-1",
State: proto.State_STATE_PENDING,
Timestamp: timestamppb.Now(),
- Inputs: []*proto.Content{
- {Role: "user", Content: &proto.Content_Text{Text: &proto.TextContent{Text: "hello"}}},
+ Inputs: []*proto.Message{
+ {Role: "user", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "hello"}}}},
},
}
@@ -48,8 +48,8 @@ func TestSQLiteEventLog_AppendAndEvents(t *testing.T) {
ExecId: "task-1",
State: proto.State_STATE_COMPLETED,
Timestamp: timestamppb.Now(),
- Outputs: []*proto.Content{
- {Role: "assistant", Content: &proto.Content_Text{Text: &proto.TextContent{Text: "world"}}},
+ Outputs: []*proto.Message{
+ {Role: "assistant", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "world"}}}},
},
}
diff --git a/internal/controller/executor/util.go b/internal/controller/executor/util.go
index 8c80600..eb66e4c 100644
--- a/internal/controller/executor/util.go
+++ b/internal/controller/executor/util.go
@@ -21,25 +21,27 @@ import (
"github.com/google/ax/proto"
)
-// agentFunc adapts a simple string→string function into the agent.Agent interface.
-type agentFunc func(input []*proto.Content, tm agent.Executor, o agent.OutputHandler)
+// agentFunc adapts a simple function into the agent.Agent interface.
+type agentFunc func(input []*proto.Message, tm agent.Executor, o agent.OutputHandler)
func (f agentFunc) Connect(ctx context.Context, execID string, start *proto.AgentStart, tm agent.Executor, o agent.OutputHandler) error {
- f(start.Contents, tm, o)
+ f(start.Messages, tm, o)
return nil
}
func (f agentFunc) HealthCheck(_ context.Context) error { return nil }
func (f agentFunc) Close() error { return nil }
-func AgentFunc(fn func(input []*proto.Content, tm agent.Executor, o agent.OutputHandler)) agent.Agent {
+func AgentFunc(fn func(input []*proto.Message, tm agent.Executor, o agent.OutputHandler)) agent.Agent {
return agentFunc(fn)
}
-// text is a helper that builds a plain-text Content.
-func text(role, s string) *proto.Content {
- return &proto.Content{
- Content: &proto.Content_Text{Text: &proto.TextContent{Text: s}},
- Role: role,
+// text is a helper that builds a plain-text Message.
+func text(role, s string) *proto.Message {
+ return &proto.Message{
+ Role: role,
+ Content: &proto.Content{
+ Content: &proto.Content_Text{Text: &proto.TextContent{Text: s}},
+ },
}
}
diff --git a/internal/controller/gemini.go b/internal/controller/gemini.go
index d45843e..fed8290 100644
--- a/internal/controller/gemini.go
+++ b/internal/controller/gemini.go
@@ -69,7 +69,7 @@ func (a *GeminiAgent) Connect(ctx context.Context, execID string, start *proto.A
return fmt.Errorf("failed to create Gemini client: %w", err)
}
- inputs := start.Contents
+ inputs := start.Messages
contents := protoToContents(inputs)
ctx, cancel := context.WithTimeout(ctx, cfg.Timeout.AsDuration())
defer cancel()
@@ -103,10 +103,12 @@ func (a *GeminiAgent) Connect(ctx context.Context, execID string, start *proto.A
if part.Text != "" {
respCount++
if err := handler(&proto.AgentOutputs{
- Contents: []*proto.Content{{
+ Messages: []*proto.Message{{
Role: "model",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{Text: part.Text},
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{Text: part.Text},
+ },
},
}},
}); err != nil {
@@ -172,21 +174,27 @@ func (t *BashTool) HandleCall(ctx context.Context, fc *genai.FunctionCall, o age
return err
}
return o(&proto.AgentOutputs{
- Contents: []*proto.Content{
+ Messages: []*proto.Message{
{
- Content: &proto.Content_FunctionCall{
- FunctionCall: &proto.FunctionCallContent{
- Id: fc.ID,
- Name: fc.Name,
- Args: argsStruct,
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_FunctionCall{
+ FunctionCall: &proto.FunctionCallContent{
+ Id: fc.ID,
+ Name: fc.Name,
+ Args: argsStruct,
+ },
},
},
},
{
- Content: &proto.Content_Confirmation{
- Confirmation: &proto.ConfirmationContent{
- Id: fc.ID,
- Question: fmt.Sprintf("Can I run %q?", command),
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_Confirmation{
+ Confirmation: &proto.ConfirmationContent{
+ Id: fc.ID,
+ Question: fmt.Sprintf("Can I run %q?", command),
+ },
},
},
}},
@@ -199,21 +207,25 @@ func (t *BashTool) HandleExecute(ctx context.Context, fc *genai.FunctionCall, ap
// But we still have to finish with a function response,
// not to keep the previously log function call hanging forever.
return o(&proto.AgentOutputs{
- Contents: []*proto.Content{
+ Messages: []*proto.Message{
{
- Role: "assistant",
- Content: &proto.Content_FunctionResponse{
- FunctionResponse: &proto.FunctionResponseContent{
- Name: fc.Name,
- Id: fc.ID,
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_FunctionResponse{
+ FunctionResponse: &proto.FunctionResponseContent{
+ Name: fc.Name,
+ Id: fc.ID,
+ },
},
},
},
{
- Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "Okay.",
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "Okay.",
+ },
},
},
},
@@ -230,22 +242,26 @@ func (t *BashTool) HandleExecute(ctx context.Context, fc *genai.FunctionCall, ap
return fmt.Errorf("failed to convert function response to structpb: %w", err)
}
return o(&proto.AgentOutputs{
- Contents: []*proto.Content{
+ Messages: []*proto.Message{
{
- Role: "assistant",
- Content: &proto.Content_FunctionResponse{
- FunctionResponse: &proto.FunctionResponseContent{
- Name: fc.Name,
- Response: respStruct,
- Id: fc.ID,
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_FunctionResponse{
+ FunctionResponse: &proto.FunctionResponseContent{
+ Name: fc.Name,
+ Response: respStruct,
+ Id: fc.ID,
+ },
},
},
},
{
- Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: output,
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: output,
+ },
},
},
},
@@ -294,34 +310,43 @@ func (t *SkillsTool) HandleCall(ctx context.Context, fc *genai.FunctionCall, o a
question := fmt.Sprintf("Can I run script %q from skill %q?", script, skill)
return o(&proto.AgentOutputs{
- Contents: []*proto.Content{
+ Messages: []*proto.Message{
{
- Content: &proto.Content_FunctionCall{
- FunctionCall: &proto.FunctionCallContent{
- Id: fc.ID,
- Name: fc.Name,
- Args: argsStruct,
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_FunctionCall{
+ FunctionCall: &proto.FunctionCallContent{
+ Id: fc.ID,
+ Name: fc.Name,
+ Args: argsStruct,
+ },
},
},
},
{
- Content: &proto.Content_Confirmation{
- Confirmation: &proto.ConfirmationContent{
- Id: fc.ID,
- Question: question,
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_Confirmation{
+ Confirmation: &proto.ConfirmationContent{
+ Id: fc.ID,
+ Question: question,
+ },
},
},
}},
})
}
return o(&proto.AgentOutputs{
- Contents: []*proto.Content{
+ Messages: []*proto.Message{
{
- Content: &proto.Content_FunctionCall{
- FunctionCall: &proto.FunctionCallContent{
- Id: fc.ID,
- Name: fc.Name,
- Args: argsStruct,
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_FunctionCall{
+ FunctionCall: &proto.FunctionCallContent{
+ Id: fc.ID,
+ Name: fc.Name,
+ Args: argsStruct,
+ },
},
},
}},
@@ -334,21 +359,25 @@ func (t *SkillsTool) HandleExecute(ctx context.Context, fc *genai.FunctionCall,
// But we still have to finish with a function response,
// not to keep the previously log function call hanging forever.
return o(&proto.AgentOutputs{
- Contents: []*proto.Content{
+ Messages: []*proto.Message{
{
- Role: "assistant",
- Content: &proto.Content_FunctionResponse{
- FunctionResponse: &proto.FunctionResponseContent{
- Name: fc.Name,
- Id: fc.ID,
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_FunctionResponse{
+ FunctionResponse: &proto.FunctionResponseContent{
+ Name: fc.Name,
+ Id: fc.ID,
+ },
},
},
},
{
- Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "Okay.",
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "Okay.",
+ },
},
},
},
@@ -378,22 +407,26 @@ func (t *SkillsTool) HandleExecute(ctx context.Context, fc *genai.FunctionCall,
return fmt.Errorf("failed to convert function response to structpb: %w", err)
}
return o(&proto.AgentOutputs{
- Contents: []*proto.Content{
+ Messages: []*proto.Message{
{
- Role: "assistant",
- Content: &proto.Content_FunctionResponse{
- FunctionResponse: &proto.FunctionResponseContent{
- Name: fc.Name,
- Response: respStruct,
- Id: fc.ID,
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_FunctionResponse{
+ FunctionResponse: &proto.FunctionResponseContent{
+ Name: fc.Name,
+ Response: respStruct,
+ Id: fc.ID,
+ },
},
},
},
{
- Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: output,
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: output,
+ },
},
},
},
diff --git a/internal/controller/gemini_planner.go b/internal/controller/gemini_planner.go
index e73f37d..690089b 100644
--- a/internal/controller/gemini_planner.go
+++ b/internal/controller/gemini_planner.go
@@ -96,9 +96,9 @@ Guidelines:
}
func (p *geminiPlannerAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {
- var outputs []*proto.Content
+ var outputs []*proto.Message
var outputCapturer = func(resp *proto.AgentOutputs) error {
- outputs = append(outputs, resp.Contents...)
+ outputs = append(outputs, resp.Messages...)
return handler(resp)
}
nextAgentID, err := p.process(ctx, start, outputCapturer)
@@ -110,7 +110,7 @@ func (p *geminiPlannerAgent) Connect(ctx context.Context, execID string, start *
}
if err := e.Exec(ctx, nextAgentID, &proto.AgentStart{
AgentId: nextAgentID,
- Contents: append(start.Contents, outputs...),
+ Messages: append(start.Messages, outputs...),
}, handler); err != nil {
return err
}
@@ -131,7 +131,7 @@ func (p *geminiPlannerAgent) process(ctx context.Context, start *proto.AgentStar
return "", fmt.Errorf("failed to convert agents to tools: %w", err)
}
- inputs := start.Contents
+ inputs := start.Messages
if fc, approved := p.handleConfirmationAnswer(inputs); fc != nil {
if p.bashTool.Name() == fc.Name {
return "", p.bashTool.HandleExecute(ctx, fc, approved, handler)
@@ -176,10 +176,12 @@ func (p *geminiPlannerAgent) process(ctx context.Context, start *proto.AgentStar
if part.Text != "" {
if err := handler(&proto.AgentOutputs{
- Contents: []*proto.Content{{
- Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{Text: part.Text},
+ Messages: []*proto.Message{{
+ Role: "model",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{Text: part.Text},
+ },
},
}},
}); err != nil {
@@ -202,16 +204,17 @@ func (p *geminiPlannerAgent) process(ctx context.Context, start *proto.AgentStar
return "", nil
}
-func (p *geminiPlannerAgent) handleConfirmationAnswer(inputs []*proto.Content) (*genai.FunctionCall, bool) {
+func (p *geminiPlannerAgent) handleConfirmationAnswer(inputs []*proto.Message) (*genai.FunctionCall, bool) {
var conf *proto.ConfirmationContent
var approved bool
for _, input := range inputs {
- if input.GetConfirmation() != nil && input.GetConfirmation().GetApproval() != nil {
- conf = input.GetConfirmation()
+ content := input.GetContent()
+ if content.GetConfirmation() != nil && content.GetConfirmation().GetApproval() != nil {
+ conf = content.GetConfirmation()
approved = true
}
- if input.GetConfirmation() != nil && input.GetConfirmation().GetDecline() != nil {
- conf = input.GetConfirmation()
+ if content.GetConfirmation() != nil && content.GetConfirmation().GetDecline() != nil {
+ conf = content.GetConfirmation()
approved = false
}
}
@@ -221,10 +224,11 @@ func (p *geminiPlannerAgent) handleConfirmationAnswer(inputs []*proto.Content) (
var fc *genai.FunctionCall
for _, input := range inputs {
- if input.GetFunctionCall() == nil {
+ content := input.GetContent()
+ if content.GetFunctionCall() == nil {
continue
}
- if fn := input.GetFunctionCall(); fn != nil && fn.Id == conf.Id {
+ if fn := content.GetFunctionCall(); fn != nil && fn.Id == conf.Id {
fc = &genai.FunctionCall{
ID: conf.Id,
Name: fn.Name,
@@ -241,10 +245,11 @@ func (p *geminiPlannerAgent) handleConfirmationAnswer(inputs []*proto.Content) (
// Ensure that we don't have a response for the function call.
// Otherwise, we will execute the function call forever.
for _, input := range inputs {
- if input.GetFunctionResponse() == nil {
+ content := input.GetContent()
+ if content.GetFunctionResponse() == nil {
continue
}
- if fr := input.GetFunctionResponse(); fr != nil && fr.Id == fc.ID {
+ if fr := content.GetFunctionResponse(); fr != nil && fr.Id == fc.ID {
// We executed this previously.
// There is nothing more to execute.
return nil, false
@@ -285,7 +290,7 @@ func agentsToTools(registry *Registry, nativeTools ...Tool) ([]*genai.Tool, erro
}
// protoToContents converts history to Gemini conversation format.
-func protoToContents(inputs []*proto.Content) []*genai.Content {
+func protoToContents(inputs []*proto.Message) []*genai.Content {
var contents []*genai.Content
// Convert each message to Gemini format
@@ -295,7 +300,12 @@ func protoToContents(inputs []*proto.Content) []*genai.Content {
role = "model"
}
- switch m := msg.Content.(type) {
+ content := msg.GetContent()
+ if content == nil {
+ continue
+ }
+
+ switch m := content.Content.(type) {
case *proto.Content_Text:
contents = append(contents, &genai.Content{
Role: role,
diff --git a/internal/historyutil/confirmations.go b/internal/historyutil/confirmations.go
index 445dc86..c3759d2 100644
--- a/internal/historyutil/confirmations.go
+++ b/internal/historyutil/confirmations.go
@@ -18,12 +18,12 @@ import "github.com/google/ax/proto"
// WaitsForConfirmation returns true if the last message in the history
// is a confirmation question waiting for user input.
-func WaitsForConfirmation(history []*proto.Content) bool {
+func WaitsForConfirmation(history []*proto.Message) bool {
if len(history) == 0 {
return false
}
last := history[len(history)-1]
- if last.GetConfirmation() != nil && last.GetConfirmation().Question != "" {
+ if last.GetContent().GetConfirmation() != nil && last.GetContent().GetConfirmation().Question != "" {
return true
}
return false
@@ -31,26 +31,26 @@ func WaitsForConfirmation(history []*proto.Content) bool {
// HasConfirmationAnswer returns true if the last message in the history
// is a confirmation question waiting for user input.
-func HasConfirmationAnswer(history []*proto.Content) (approved bool, conf *proto.ConfirmationContent) {
+func HasConfirmationAnswer(history []*proto.Message) (approved bool, conf *proto.ConfirmationContent) {
if len(history) == 0 {
return false, nil
}
last := history[len(history)-1]
- if last.GetConfirmation() == nil {
+ if last.GetContent().GetConfirmation() == nil {
return false, nil
}
- if last.GetConfirmation().GetApproval() != nil {
- conf = last.GetConfirmation()
+ if last.GetContent().GetConfirmation().GetApproval() != nil {
+ conf = last.GetContent().GetConfirmation()
approved = true
}
- if last.GetConfirmation().GetDecline() != nil {
- conf = last.GetConfirmation()
+ if last.GetContent().GetConfirmation().GetDecline() != nil {
+ conf = last.GetContent().GetConfirmation()
approved = false
}
return approved, conf
}
-func WaitsForUser(history []*proto.Content) bool {
+func WaitsForUser(history []*proto.Message) bool {
if len(history) == 0 {
return false
}
@@ -59,7 +59,7 @@ func WaitsForUser(history []*proto.Content) bool {
}
last := history[len(history)-1]
- if last.GetConfirmation() != nil && last.GetConfirmation().GetDecline() != nil {
+ if last.GetContent().GetConfirmation() != nil && last.GetContent().GetConfirmation().GetDecline() != nil {
return true
}
return false
diff --git a/internal/server/server.go b/internal/server/server.go
index 0f93aae..6dfefca 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -50,7 +50,7 @@ func (s *Server) Exec(req *proto.ExecRequest, stream grpc.ServerStreamingServer[
// Create output handler to stream outputs back to client
outputHandler := agent.OutputHandler(func(outgoing *proto.AgentOutputs) error {
return stream.Send(&proto.ExecResponse{
- Outputs: outgoing.Contents,
+ Outputs: outgoing.Messages,
})
})
return s.controller.Exec(stream.Context(), &proto.AgentMessage{
@@ -59,7 +59,7 @@ func (s *Server) Exec(req *proto.ExecRequest, stream grpc.ServerStreamingServer[
Start: &proto.AgentStart{
AgentId: req.AgentId,
Config: req.AgentConfig,
- Contents: req.Inputs,
+ Messages: req.Inputs,
},
},
}, outputHandler)
diff --git a/internal/test_multi/test_multi.go b/internal/test_multi/test_multi.go
index 8b23b20..43e6a78 100644
--- a/internal/test_multi/test_multi.go
+++ b/internal/test_multi/test_multi.go
@@ -82,12 +82,14 @@ func main() {
log.Fatalf("Error registering sandbox agent: %v\n", err)
}
- inputs := []*proto.Content{
+ inputs := []*proto.Message{
{
Role: "user",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: input,
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: input,
+ },
},
},
},
@@ -96,8 +98,8 @@ func main() {
log.Printf("ID: %s\n", execID)
handler := agent.OutputHandler(func(outgoing *proto.AgentOutputs) error {
- for _, c := range outgoing.Contents {
- if textContent := c.GetText(); textContent != nil {
+ for _, m := range outgoing.Messages {
+ if textContent := m.GetContent().GetText(); textContent != nil {
fmt.Printf("Output received: %s\n", textContent.Text)
}
}
@@ -109,7 +111,7 @@ func main() {
Msg: &proto.AgentMessage_Start{
Start: &proto.AgentStart{
AgentId: "planner",
- Contents: inputs,
+ Messages: inputs,
},
},
}
@@ -125,7 +127,7 @@ func main() {
Msg: &proto.AgentMessage_Start{
Start: &proto.AgentStart{
AgentId: "planner",
- Contents: inputs,
+ Messages: inputs,
},
},
}
@@ -134,18 +136,24 @@ func main() {
func createLocalAgent() (*agent.LocalAgent, error) {
processFunc := func(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {
- for _, content := range start.Contents {
+ for _, msg := range start.Messages {
+ content := msg.GetContent()
+ if content == nil {
+ continue
+ }
textContent := content.GetText()
if textContent == nil {
continue
}
if err := handler(&proto.AgentOutputs{
- Contents: []*proto.Content{
+ Messages: []*proto.Message{
{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: strings.ToLower(textContent.Text),
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: strings.ToLower(textContent.Text),
+ },
},
},
},
@@ -171,62 +179,70 @@ func (m *mockPlanner) HealthCheck(ctx context.Context) error { return nil }
func (m *mockPlanner) Close() error { return nil }
func (m *mockPlanner) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {
var lastText string
- for _, c := range start.Contents {
- if textMsg := c.GetText(); textMsg != nil {
+ for _, m := range start.Messages {
+ if textMsg := m.GetContent().GetText(); textMsg != nil {
lastText = textMsg.Text
}
}
// Step 1: User -> Local
if strings.HasPrefix(lastText, "Send the word") {
- inputs := append(start.Contents, &proto.Content{
+ inputs := append(start.Messages, &proto.Message{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{Text: "oRanGe"},
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{Text: "oRanGe"},
+ },
},
})
return e.Exec(ctx, "local-echo", &proto.AgentStart{
AgentId: "local-echo-agent",
- Contents: inputs,
+ Messages: inputs,
}, handler)
}
// Step 2: Local -> Remote
if lastText == "orange" {
- inputs := append(start.Contents, &proto.Content{
+ inputs := append(start.Messages, &proto.Message{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{Text: lastText},
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{Text: lastText},
+ },
},
})
return e.Exec(ctx, "remote-text", &proto.AgentStart{
AgentId: "remote-text-processor",
- Contents: inputs,
+ Messages: inputs,
}, handler)
}
// Step 3: Remote -> Sandbox
if strings.HasPrefix(lastText, "Remote Prefix:") {
- inputs := append(start.Contents, &proto.Content{
+ inputs := append(start.Messages, &proto.Message{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{Text: lastText},
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{Text: lastText},
+ },
},
})
return e.Exec(ctx, "uppercase-task", &proto.AgentStart{
AgentId: "uppercase",
- Contents: inputs,
+ Messages: inputs,
}, handler)
}
// Final step: Sandbox -> Done
if strings.Contains(lastText, "UPPERCASE") {
return handler(&proto.AgentOutputs{
- Contents: []*proto.Content{{
+ Messages: []*proto.Message{{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "Final Result: " + lastText,
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "Final Result: " + lastText,
+ },
},
},
}},
diff --git a/internal/testagent/agent.go b/internal/testagent/agent.go
index 896807d..0a7bf4d 100644
--- a/internal/testagent/agent.go
+++ b/internal/testagent/agent.go
@@ -45,22 +45,24 @@ type CodingAgent struct{}
func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {
exec := NewExecutor(e, o)
- var history []*proto.Content
+ var history []*proto.Message
{
- inputs := []*proto.Content{
+ inputs := []*proto.Message{
{
Role: "user",
- Content: &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.",
+ Content: &proto.Content{
+ Content: &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.",
+ },
},
},
},
}
- inputs = append(inputs, start.Contents...)
+ inputs = append(inputs, start.Messages...)
outputs, err := exec.Exec(ctx, "code", &proto.AgentStart{
AgentId: "gemini",
- Contents: inputs,
+ Messages: inputs,
})
if err != nil {
return err
@@ -71,7 +73,7 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.A
{
outputs, err := exec.Exec(ctx, "docker", &proto.AgentStart{
AgentId: "docker-build",
- Contents: history,
+ Messages: history,
})
if err != nil {
return err
@@ -88,7 +90,7 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.A
}
outputs, err := exec.Exec(ctx, "deploy", &proto.AgentStart{
AgentId: "kubernetes-deploy",
- Contents: history,
+ Messages: history,
Config: config,
})
if err != nil {
@@ -111,7 +113,7 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.A
}
outputs, err := exec.Exec(ctx, "deploy-more", &proto.AgentStart{
AgentId: "kubernetes-deploy",
- Contents: history,
+ Messages: history,
Config: config,
})
if err != nil {
@@ -125,11 +127,13 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.A
}
if err := o(&proto.AgentOutputs{
- Contents: []*proto.Content{{
+ Messages: []*proto.Message{{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "One last step, a summary...\n\n",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "One last step, a summary...\n\n",
+ },
},
},
}},
@@ -138,17 +142,19 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.A
}
{
- history = append(history, &proto.Content{
+ history = append(history, &proto.Message{
Role: "user",
- Content: &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",
+ Content: &proto.Content{
+ Content: &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",
+ },
},
},
})
_, err := exec.Exec(ctx, "summarize", &proto.AgentStart{
AgentId: "gemini",
- Contents: history,
+ Messages: history,
})
if err != nil {
return err
@@ -174,7 +180,7 @@ type KubernetesDeployAgent struct{}
func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {
exec := NewExecutor(e, o)
- approved, conf := historyutil.HasConfirmationAnswer(start.Contents)
+ approved, conf := historyutil.HasConfirmationAnswer(start.Messages)
if conf != nil && pendingRegions[conf.Id] != nil {
if !approved {
return nil
@@ -182,11 +188,13 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
regions := pendingRegions[conf.Id]
if err := o(&proto.AgentOutputs{
- Contents: []*proto.Content{{
+ Messages: []*proto.Message{{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: fmt.Sprintf("\nPicked %v region(s) for deployment.\n", strings.Join(regions, ",")),
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: fmt.Sprintf("\nPicked %v region(s) for deployment.\n", strings.Join(regions, ",")),
+ },
},
},
}},
@@ -198,12 +206,14 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
if region != "us-central1" {
_, err := exec.Exec(ctx, "mirror-"+region, &proto.AgentStart{
AgentId: "docker-mirror",
- Contents: []*proto.Content{
+ Messages: []*proto.Message{
{
Role: "user",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "Provide a mirror to the region if the image doesn't exist.",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "Provide a mirror to the region if the image doesn't exist.",
+ },
},
},
},
@@ -214,11 +224,13 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
}
}
if err := o(&proto.AgentOutputs{
- Contents: []*proto.Content{{
+ Messages: []*proto.Message{{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "* Deploying to " + region + ", this may take a while...\n",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "* Deploying to " + region + ", this may take a while...\n",
+ },
},
},
}},
@@ -226,11 +238,13 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
return err
}
if err := o(&proto.AgentOutputs{
- Contents: []*proto.Content{{
+ Messages: []*proto.Message{{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "* kubectl apply -f deployment.yaml\n",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "* kubectl apply -f deployment.yaml\n",
+ },
},
},
}},
@@ -240,11 +254,13 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
time.Sleep(1500 * time.Millisecond)
if err := o(&proto.AgentOutputs{
- Contents: []*proto.Content{{
+ Messages: []*proto.Message{{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: fmt.Sprintf("* Deployment complete. You can access the service at https://%v.test.services.acme.com\n\n", region),
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: fmt.Sprintf("* Deployment complete. You can access the service at https://%v.test.services.acme.com\n\n", region),
+ },
},
},
}},
@@ -270,12 +286,14 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
confID := uuid.NewString()
pendingRegions[confID] = config.Regions
return o(&proto.AgentOutputs{
- Contents: []*proto.Content{{
+ Messages: []*proto.Message{{
Role: "assistant",
- Content: &proto.Content_Confirmation{
- Confirmation: &proto.ConfirmationContent{
- Id: confID,
- Question: fmt.Sprintf("Picked %v region(s) to deploy, continue?", strings.Join(config.Regions, ",")),
+ Content: &proto.Content{
+ Content: &proto.Content_Confirmation{
+ Confirmation: &proto.ConfirmationContent{
+ Id: confID,
+ Question: fmt.Sprintf("Picked %v region(s) to deploy, continue?", strings.Join(config.Regions, ",")),
+ },
},
},
}},
@@ -303,8 +321,8 @@ func NewExecutor(e agent.Executor, o agent.OutputHandler) *Executor {
}
}
-func (e *Executor) Exec(ctx context.Context, execID string, start *proto.AgentStart) ([]*proto.Content, error) {
- var outputs []*proto.Content
+func (e *Executor) Exec(ctx context.Context, execID string, start *proto.AgentStart) ([]*proto.Message, error) {
+ var outputs []*proto.Message
if execID == "" {
var err error
execID, err = randomHex(8)
@@ -313,7 +331,7 @@ func (e *Executor) Exec(ctx context.Context, execID string, start *proto.AgentSt
}
}
if err := e.exec.Exec(ctx, execID, start, func(resp *proto.AgentOutputs) error {
- outputs = append(outputs, resp.Contents...)
+ outputs = append(outputs, resp.Messages...)
return e.handler(resp)
}); err != nil {
return nil, err
diff --git a/internal/testagent/docker.go b/internal/testagent/docker.go
index 847f1e1..499c6d9 100644
--- a/internal/testagent/docker.go
+++ b/internal/testagent/docker.go
@@ -26,11 +26,13 @@ type DockerBuilderAgent struct{}
func (a *DockerBuilderAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {
o(&proto.AgentOutputs{
- Contents: []*proto.Content{{
+ Messages: []*proto.Message{{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "\n\nBuilding the docker image now...\n",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "\n\nBuilding the docker image now...\n",
+ },
},
},
}},
@@ -38,11 +40,13 @@ func (a *DockerBuilderAgent) Connect(ctx context.Context, execID string, start *
time.Sleep(500 * time.Millisecond)
o(&proto.AgentOutputs{
- Contents: []*proto.Content{{
+ Messages: []*proto.Message{{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "* us-central1-docker.pkg.dev/acme/test/test:latest is built and is ready to push.\n",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "* us-central1-docker.pkg.dev/acme/test/test:latest is built and is ready to push.\n",
+ },
},
},
}},
@@ -50,11 +54,13 @@ func (a *DockerBuilderAgent) Connect(ctx context.Context, execID string, start *
time.Sleep(1000 * time.Millisecond)
o(&proto.AgentOutputs{
- Contents: []*proto.Content{{
+ Messages: []*proto.Message{{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "* The container image is pushed.\n\n",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "* The container image is pushed.\n\n",
+ },
},
},
}},
@@ -75,11 +81,13 @@ type DockerMirrorAgent struct{}
func (a *DockerMirrorAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {
o(&proto.AgentOutputs{
- Contents: []*proto.Content{{
+ Messages: []*proto.Message{{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "* Starting pushing docker image now...\n",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "* Starting pushing docker image now...\n",
+ },
},
},
}},
@@ -87,11 +95,13 @@ func (a *DockerMirrorAgent) Connect(ctx context.Context, execID string, start *p
time.Sleep(2000 * time.Millisecond)
o(&proto.AgentOutputs{
- Contents: []*proto.Content{{
+ Messages: []*proto.Message{{
Role: "assistant",
- Content: &proto.Content_Text{
- Text: &proto.TextContent{
- Text: "* The container image is mirrored.\n",
+ Content: &proto.Content{
+ Content: &proto.Content_Text{
+ Text: &proto.TextContent{
+ Text: "* The container image is mirrored.\n",
+ },
},
},
}},
diff --git a/proto/ax.pb.go b/proto/ax.pb.go
index 1a257d1..b64b725 100644
--- a/proto/ax.pb.go
+++ b/proto/ax.pb.go
@@ -96,7 +96,7 @@ type AgentStart struct {
state protoimpl.MessageState `protogen:"open.v1"`
AgentId string `protobuf:"bytes,1,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"`
Config *anypb.Any `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"`
- Contents []*Content `protobuf:"bytes,3,rep,name=contents,proto3" json:"contents,omitempty"`
+ Messages []*Message `protobuf:"bytes,3,rep,name=messages,proto3" json:"messages,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -145,16 +145,16 @@ func (x *AgentStart) GetConfig() *anypb.Any {
return nil
}
-func (x *AgentStart) GetContents() []*Content {
+func (x *AgentStart) GetMessages() []*Message {
if x != nil {
- return x.Contents
+ return x.Messages
}
return nil
}
type AgentOutputs struct {
state protoimpl.MessageState `protogen:"open.v1"`
- Contents []*Content `protobuf:"bytes,1,rep,name=contents,proto3" json:"contents,omitempty"`
+ Messages []*Message `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
CheckpointId string `protobuf:"bytes,2,opt,name=checkpoint_id,json=checkpointId,proto3" json:"checkpoint_id,omitempty"` // TODO: Add awaiting_more field.
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@@ -190,9 +190,9 @@ func (*AgentOutputs) Descriptor() ([]byte, []int) {
return file_proto_ax_proto_rawDescGZIP(), []int{1}
}
-func (x *AgentOutputs) GetContents() []*Content {
+func (x *AgentOutputs) GetMessages() []*Message {
if x != nil {
- return x.Contents
+ return x.Messages
}
return nil
}
@@ -653,7 +653,7 @@ func (x *FunctionResponseContent) GetId() string {
return ""
}
-// Content represents a message with role, type, mimetype, and data fields
+// 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:
@@ -663,7 +663,6 @@ type Content struct {
// *Content_FunctionCall
// *Content_FunctionResponse
Content isContent_Content `protobuf_oneof:"content"`
- Role string `protobuf:"bytes,1000,opt,name=role,proto3" json:"role,omitempty"` // The role of the content (e.g., "user", "assistant", "system")
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -741,13 +740,6 @@ func (x *Content) GetFunctionResponse() *FunctionResponseContent {
return nil
}
-func (x *Content) GetRole() string {
- if x != nil {
- return x.Role
- }
- return ""
-}
-
type isContent_Content interface {
isContent_Content()
}
@@ -776,6 +768,59 @@ func (*Content_FunctionCall) isContent_Content() {}
func (*Content_FunctionResponse) isContent_Content() {}
+// Message is a message in the history.
+type Message struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` // user, assistant, or model
+ Content *Content `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` // content of the message
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *Message) Reset() {
+ *x = Message{}
+ mi := &file_proto_ax_proto_msgTypes[10]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *Message) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Message) ProtoMessage() {}
+
+func (x *Message) ProtoReflect() protoreflect.Message {
+ mi := &file_proto_ax_proto_msgTypes[10]
+ 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 Message.ProtoReflect.Descriptor instead.
+func (*Message) Descriptor() ([]byte, []int) {
+ return file_proto_ax_proto_rawDescGZIP(), []int{10}
+}
+
+func (x *Message) GetRole() string {
+ if x != nil {
+ return x.Role
+ }
+ return ""
+}
+
+func (x *Message) GetContent() *Content {
+ if x != nil {
+ return x.Content
+ }
+ return nil
+}
+
// ExecutionEvent is the entry in the event log. ExecutionEvents are used
// to record the actions taken place in the executor.
// The executor can replay the events for resumability.
@@ -783,8 +828,8 @@ type ExecutionEvent struct {
state protoimpl.MessageState `protogen:"open.v1"`
ExecId string `protobuf:"bytes,1,opt,name=exec_id,json=execId,proto3" json:"exec_id,omitempty"`
AgentId string `protobuf:"bytes,2,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"`
- Inputs []*Content `protobuf:"bytes,3,rep,name=inputs,proto3" json:"inputs,omitempty"`
- Outputs []*Content `protobuf:"bytes,4,rep,name=outputs,proto3" json:"outputs,omitempty"`
+ Inputs []*Message `protobuf:"bytes,3,rep,name=inputs,proto3" json:"inputs,omitempty"`
+ Outputs []*Message `protobuf:"bytes,4,rep,name=outputs,proto3" json:"outputs,omitempty"`
State State `protobuf:"varint,5,opt,name=state,proto3,enum=proto.State" json:"state,omitempty"`
Timestamp *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // string checkpoint_id = 10;
unknownFields protoimpl.UnknownFields
@@ -793,7 +838,7 @@ type ExecutionEvent struct {
func (x *ExecutionEvent) Reset() {
*x = ExecutionEvent{}
- mi := &file_proto_ax_proto_msgTypes[10]
+ mi := &file_proto_ax_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -805,7 +850,7 @@ func (x *ExecutionEvent) String() string {
func (*ExecutionEvent) ProtoMessage() {}
func (x *ExecutionEvent) ProtoReflect() protoreflect.Message {
- mi := &file_proto_ax_proto_msgTypes[10]
+ mi := &file_proto_ax_proto_msgTypes[11]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -818,7 +863,7 @@ func (x *ExecutionEvent) ProtoReflect() protoreflect.Message {
// Deprecated: Use ExecutionEvent.ProtoReflect.Descriptor instead.
func (*ExecutionEvent) Descriptor() ([]byte, []int) {
- return file_proto_ax_proto_rawDescGZIP(), []int{10}
+ return file_proto_ax_proto_rawDescGZIP(), []int{11}
}
func (x *ExecutionEvent) GetExecId() string {
@@ -835,14 +880,14 @@ func (x *ExecutionEvent) GetAgentId() string {
return ""
}
-func (x *ExecutionEvent) GetInputs() []*Content {
+func (x *ExecutionEvent) GetInputs() []*Message {
if x != nil {
return x.Inputs
}
return nil
}
-func (x *ExecutionEvent) GetOutputs() []*Content {
+func (x *ExecutionEvent) GetOutputs() []*Message {
if x != nil {
return x.Outputs
}
@@ -872,7 +917,7 @@ type HealthCheckRequest struct {
func (x *HealthCheckRequest) Reset() {
*x = HealthCheckRequest{}
- mi := &file_proto_ax_proto_msgTypes[11]
+ mi := &file_proto_ax_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -884,7 +929,7 @@ func (x *HealthCheckRequest) String() string {
func (*HealthCheckRequest) ProtoMessage() {}
func (x *HealthCheckRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_ax_proto_msgTypes[11]
+ mi := &file_proto_ax_proto_msgTypes[12]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -897,7 +942,7 @@ func (x *HealthCheckRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use HealthCheckRequest.ProtoReflect.Descriptor instead.
func (*HealthCheckRequest) Descriptor() ([]byte, []int) {
- return file_proto_ax_proto_rawDescGZIP(), []int{11}
+ return file_proto_ax_proto_rawDescGZIP(), []int{12}
}
// HealthCheckResponse contains agent health status
@@ -911,7 +956,7 @@ type HealthCheckResponse struct {
func (x *HealthCheckResponse) Reset() {
*x = HealthCheckResponse{}
- mi := &file_proto_ax_proto_msgTypes[12]
+ mi := &file_proto_ax_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -923,7 +968,7 @@ func (x *HealthCheckResponse) String() string {
func (*HealthCheckResponse) ProtoMessage() {}
func (x *HealthCheckResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_ax_proto_msgTypes[12]
+ mi := &file_proto_ax_proto_msgTypes[13]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -936,7 +981,7 @@ func (x *HealthCheckResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use HealthCheckResponse.ProtoReflect.Descriptor instead.
func (*HealthCheckResponse) Descriptor() ([]byte, []int) {
- return file_proto_ax_proto_rawDescGZIP(), []int{12}
+ return file_proto_ax_proto_rawDescGZIP(), []int{13}
}
func (x *HealthCheckResponse) GetHealthy() bool {
@@ -959,14 +1004,14 @@ type ExecRequest struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // Unique execution identifier
AgentId string `protobuf:"bytes,2,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"` // Agent ID, if empty planner is used
AgentConfig *anypb.Any `protobuf:"bytes,3,opt,name=agent_config,json=agentConfig,proto3" json:"agent_config,omitempty"` // Agent configuration if any
- Inputs []*Content `protobuf:"bytes,4,rep,name=inputs,proto3" json:"inputs,omitempty"` // Input content to process
+ Inputs []*Message `protobuf:"bytes,4,rep,name=inputs,proto3" json:"inputs,omitempty"` // Input content to process
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ExecRequest) Reset() {
*x = ExecRequest{}
- mi := &file_proto_ax_proto_msgTypes[13]
+ mi := &file_proto_ax_proto_msgTypes[14]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -978,7 +1023,7 @@ func (x *ExecRequest) String() string {
func (*ExecRequest) ProtoMessage() {}
func (x *ExecRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_ax_proto_msgTypes[13]
+ mi := &file_proto_ax_proto_msgTypes[14]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -991,7 +1036,7 @@ func (x *ExecRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use ExecRequest.ProtoReflect.Descriptor instead.
func (*ExecRequest) Descriptor() ([]byte, []int) {
- return file_proto_ax_proto_rawDescGZIP(), []int{13}
+ return file_proto_ax_proto_rawDescGZIP(), []int{14}
}
func (x *ExecRequest) GetId() string {
@@ -1015,7 +1060,7 @@ func (x *ExecRequest) GetAgentConfig() *anypb.Any {
return nil
}
-func (x *ExecRequest) GetInputs() []*Content {
+func (x *ExecRequest) GetInputs() []*Message {
if x != nil {
return x.Inputs
}
@@ -1025,14 +1070,14 @@ func (x *ExecRequest) GetInputs() []*Content {
// ExecResponse contains the result of an execution.
type ExecResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
- Outputs []*Content `protobuf:"bytes,1,rep,name=outputs,proto3" json:"outputs,omitempty"` // Output content
+ Outputs []*Message `protobuf:"bytes,1,rep,name=outputs,proto3" json:"outputs,omitempty"` // Output content
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ExecResponse) Reset() {
*x = ExecResponse{}
- mi := &file_proto_ax_proto_msgTypes[14]
+ mi := &file_proto_ax_proto_msgTypes[15]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1044,7 +1089,7 @@ func (x *ExecResponse) String() string {
func (*ExecResponse) ProtoMessage() {}
func (x *ExecResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_ax_proto_msgTypes[14]
+ mi := &file_proto_ax_proto_msgTypes[15]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1057,10 +1102,10 @@ func (x *ExecResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use ExecResponse.ProtoReflect.Descriptor instead.
func (*ExecResponse) Descriptor() ([]byte, []int) {
- return file_proto_ax_proto_rawDescGZIP(), []int{14}
+ return file_proto_ax_proto_rawDescGZIP(), []int{15}
}
-func (x *ExecResponse) GetOutputs() []*Content {
+func (x *ExecResponse) GetOutputs() []*Message {
if x != nil {
return x.Outputs
}
@@ -1078,7 +1123,7 @@ type ForkRequest struct {
func (x *ForkRequest) Reset() {
*x = ForkRequest{}
- mi := &file_proto_ax_proto_msgTypes[15]
+ mi := &file_proto_ax_proto_msgTypes[16]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1090,7 +1135,7 @@ func (x *ForkRequest) String() string {
func (*ForkRequest) ProtoMessage() {}
func (x *ForkRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_ax_proto_msgTypes[15]
+ mi := &file_proto_ax_proto_msgTypes[16]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1103,7 +1148,7 @@ func (x *ForkRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use ForkRequest.ProtoReflect.Descriptor instead.
func (*ForkRequest) Descriptor() ([]byte, []int) {
- return file_proto_ax_proto_rawDescGZIP(), []int{15}
+ return file_proto_ax_proto_rawDescGZIP(), []int{16}
}
func (x *ForkRequest) GetSrcId() string {
@@ -1136,7 +1181,7 @@ type ForkResponse struct {
func (x *ForkResponse) Reset() {
*x = ForkResponse{}
- mi := &file_proto_ax_proto_msgTypes[16]
+ mi := &file_proto_ax_proto_msgTypes[17]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1148,7 +1193,7 @@ func (x *ForkResponse) String() string {
func (*ForkResponse) ProtoMessage() {}
func (x *ForkResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_ax_proto_msgTypes[16]
+ mi := &file_proto_ax_proto_msgTypes[17]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1161,7 +1206,7 @@ func (x *ForkResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use ForkResponse.ProtoReflect.Descriptor instead.
func (*ForkResponse) Descriptor() ([]byte, []int) {
- return file_proto_ax_proto_rawDescGZIP(), []int{16}
+ return file_proto_ax_proto_rawDescGZIP(), []int{17}
}
func (x *ForkResponse) GetNewId() string {
@@ -1180,7 +1225,7 @@ type RemoteAgentConfig struct {
func (x *RemoteAgentConfig) Reset() {
*x = RemoteAgentConfig{}
- mi := &file_proto_ax_proto_msgTypes[17]
+ mi := &file_proto_ax_proto_msgTypes[18]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1192,7 +1237,7 @@ func (x *RemoteAgentConfig) String() string {
func (*RemoteAgentConfig) ProtoMessage() {}
func (x *RemoteAgentConfig) ProtoReflect() protoreflect.Message {
- mi := &file_proto_ax_proto_msgTypes[17]
+ mi := &file_proto_ax_proto_msgTypes[18]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1205,7 +1250,7 @@ func (x *RemoteAgentConfig) ProtoReflect() protoreflect.Message {
// Deprecated: Use RemoteAgentConfig.ProtoReflect.Descriptor instead.
func (*RemoteAgentConfig) Descriptor() ([]byte, []int) {
- return file_proto_ax_proto_rawDescGZIP(), []int{17}
+ return file_proto_ax_proto_rawDescGZIP(), []int{18}
}
func (x *RemoteAgentConfig) GetAddress() string {
@@ -1232,7 +1277,7 @@ type RegisterAgentRequest struct {
func (x *RegisterAgentRequest) Reset() {
*x = RegisterAgentRequest{}
- mi := &file_proto_ax_proto_msgTypes[18]
+ mi := &file_proto_ax_proto_msgTypes[19]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1244,7 +1289,7 @@ func (x *RegisterAgentRequest) String() string {
func (*RegisterAgentRequest) ProtoMessage() {}
func (x *RegisterAgentRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_ax_proto_msgTypes[18]
+ mi := &file_proto_ax_proto_msgTypes[19]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1257,7 +1302,7 @@ func (x *RegisterAgentRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use RegisterAgentRequest.ProtoReflect.Descriptor instead.
func (*RegisterAgentRequest) Descriptor() ([]byte, []int) {
- return file_proto_ax_proto_rawDescGZIP(), []int{18}
+ return file_proto_ax_proto_rawDescGZIP(), []int{19}
}
func (x *RegisterAgentRequest) GetAgentId() string {
@@ -1323,7 +1368,7 @@ type RegisterAgentResponse struct {
func (x *RegisterAgentResponse) Reset() {
*x = RegisterAgentResponse{}
- mi := &file_proto_ax_proto_msgTypes[19]
+ mi := &file_proto_ax_proto_msgTypes[20]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1335,7 +1380,7 @@ func (x *RegisterAgentResponse) String() string {
func (*RegisterAgentResponse) ProtoMessage() {}
func (x *RegisterAgentResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_ax_proto_msgTypes[19]
+ mi := &file_proto_ax_proto_msgTypes[20]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1348,7 +1393,7 @@ func (x *RegisterAgentResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use RegisterAgentResponse.ProtoReflect.Descriptor instead.
func (*RegisterAgentResponse) Descriptor() ([]byte, []int) {
- return file_proto_ax_proto_rawDescGZIP(), []int{19}
+ return file_proto_ax_proto_rawDescGZIP(), []int{20}
}
// GeminiConfig is the configuration for a Gemini agent.
@@ -1364,7 +1409,7 @@ type GeminiConfig struct {
func (x *GeminiConfig) Reset() {
*x = GeminiConfig{}
- mi := &file_proto_ax_proto_msgTypes[20]
+ mi := &file_proto_ax_proto_msgTypes[21]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1376,7 +1421,7 @@ func (x *GeminiConfig) String() string {
func (*GeminiConfig) ProtoMessage() {}
func (x *GeminiConfig) ProtoReflect() protoreflect.Message {
- mi := &file_proto_ax_proto_msgTypes[20]
+ mi := &file_proto_ax_proto_msgTypes[21]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1389,7 +1434,7 @@ func (x *GeminiConfig) ProtoReflect() protoreflect.Message {
// Deprecated: Use GeminiConfig.ProtoReflect.Descriptor instead.
func (*GeminiConfig) Descriptor() ([]byte, []int) {
- return file_proto_ax_proto_rawDescGZIP(), []int{20}
+ return file_proto_ax_proto_rawDescGZIP(), []int{21}
}
func (x *GeminiConfig) GetModel() string {
@@ -1429,9 +1474,9 @@ const file_proto_ax_proto_rawDesc = "" +
"AgentStart\x12\x19\n" +
"\bagent_id\x18\x01 \x01(\tR\aagentId\x12,\n" +
"\x06config\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x06config\x12*\n" +
- "\bcontents\x18\x03 \x03(\v2\x0e.proto.ContentR\bcontents\"_\n" +
+ "\bmessages\x18\x03 \x03(\v2\x0e.proto.MessageR\bmessages\"_\n" +
"\fAgentOutputs\x12*\n" +
- "\bcontents\x18\x01 \x03(\v2\x0e.proto.ContentR\bcontents\x12#\n" +
+ "\bmessages\x18\x01 \x03(\v2\x0e.proto.MessageR\bmessages\x12#\n" +
"\rcheckpoint_id\x18\x02 \x01(\tR\fcheckpointId\"\x8a\x01\n" +
"\fAgentMessage\x12\x17\n" +
"\aexec_id\x18\x01 \x01(\tR\x06execId\x12)\n" +
@@ -1459,21 +1504,23 @@ const file_proto_ax_proto_rawDesc = "" +
"\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\"\xb9\x02\n" +
+ "\x02id\x18\x03 \x01(\tR\x02id\"\xa4\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\x10functionResponse\x12\x13\n" +
- "\x04role\x18\xe8\a \x01(\tR\x04roleB\t\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\x1a\"\xf4\x01\n" +
+ "J\x04\b\v\x10\x1a\"G\n" +
+ "\aMessage\x12\x12\n" +
+ "\x04role\x18\x01 \x01(\tR\x04role\x12(\n" +
+ "\acontent\x18\x02 \x01(\v2\x0e.proto.ContentR\acontent\"\xf4\x01\n" +
"\x0eExecutionEvent\x12\x17\n" +
"\aexec_id\x18\x01 \x01(\tR\x06execId\x12\x19\n" +
"\bagent_id\x18\x02 \x01(\tR\aagentId\x12&\n" +
- "\x06inputs\x18\x03 \x03(\v2\x0e.proto.ContentR\x06inputs\x12(\n" +
- "\aoutputs\x18\x04 \x03(\v2\x0e.proto.ContentR\aoutputs\x12\"\n" +
+ "\x06inputs\x18\x03 \x03(\v2\x0e.proto.MessageR\x06inputs\x12(\n" +
+ "\aoutputs\x18\x04 \x03(\v2\x0e.proto.MessageR\aoutputs\x12\"\n" +
"\x05state\x18\x05 \x01(\x0e2\f.proto.StateR\x05state\x128\n" +
"\ttimestamp\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\ttimestamp\"\x14\n" +
"\x12HealthCheckRequest\"I\n" +
@@ -1484,9 +1531,9 @@ const file_proto_ax_proto_rawDesc = "" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x19\n" +
"\bagent_id\x18\x02 \x01(\tR\aagentId\x127\n" +
"\fagent_config\x18\x03 \x01(\v2\x14.google.protobuf.AnyR\vagentConfig\x12&\n" +
- "\x06inputs\x18\x04 \x03(\v2\x0e.proto.ContentR\x06inputs\"8\n" +
+ "\x06inputs\x18\x04 \x03(\v2\x0e.proto.MessageR\x06inputs\"8\n" +
"\fExecResponse\x12(\n" +
- "\aoutputs\x18\x01 \x03(\v2\x0e.proto.ContentR\aoutputs\"i\n" +
+ "\aoutputs\x18\x01 \x03(\v2\x0e.proto.MessageR\aoutputs\"i\n" +
"\vForkRequest\x12\x15\n" +
"\x06src_id\x18\x01 \x01(\tR\x05srcId\x12*\n" +
"\x11src_checkpoint_id\x18\x02 \x01(\tR\x0fsrcCheckpointId\x12\x17\n" +
@@ -1538,7 +1585,7 @@ func file_proto_ax_proto_rawDescGZIP() []byte {
}
var file_proto_ax_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
-var file_proto_ax_proto_msgTypes = make([]protoimpl.MessageInfo, 22)
+var file_proto_ax_proto_msgTypes = make([]protoimpl.MessageInfo, 23)
var file_proto_ax_proto_goTypes = []any{
(State)(0), // 0: proto.State
(*AgentStart)(nil), // 1: proto.AgentStart
@@ -1551,62 +1598,64 @@ var file_proto_ax_proto_goTypes = []any{
(*FunctionCallContent)(nil), // 8: proto.FunctionCallContent
(*FunctionResponseContent)(nil), // 9: proto.FunctionResponseContent
(*Content)(nil), // 10: proto.Content
- (*ExecutionEvent)(nil), // 11: proto.ExecutionEvent
- (*HealthCheckRequest)(nil), // 12: proto.HealthCheckRequest
- (*HealthCheckResponse)(nil), // 13: proto.HealthCheckResponse
- (*ExecRequest)(nil), // 14: proto.ExecRequest
- (*ExecResponse)(nil), // 15: proto.ExecResponse
- (*ForkRequest)(nil), // 16: proto.ForkRequest
- (*ForkResponse)(nil), // 17: proto.ForkResponse
- (*RemoteAgentConfig)(nil), // 18: proto.RemoteAgentConfig
- (*RegisterAgentRequest)(nil), // 19: proto.RegisterAgentRequest
- (*RegisterAgentResponse)(nil), // 20: proto.RegisterAgentResponse
- (*GeminiConfig)(nil), // 21: proto.GeminiConfig
- nil, // 22: proto.RegisterAgentRequest.MetadataEntry
- (*anypb.Any)(nil), // 23: google.protobuf.Any
- (*structpb.Struct)(nil), // 24: google.protobuf.Struct
- (*timestamppb.Timestamp)(nil), // 25: google.protobuf.Timestamp
- (*durationpb.Duration)(nil), // 26: google.protobuf.Duration
+ (*Message)(nil), // 11: proto.Message
+ (*ExecutionEvent)(nil), // 12: proto.ExecutionEvent
+ (*HealthCheckRequest)(nil), // 13: proto.HealthCheckRequest
+ (*HealthCheckResponse)(nil), // 14: proto.HealthCheckResponse
+ (*ExecRequest)(nil), // 15: proto.ExecRequest
+ (*ExecResponse)(nil), // 16: proto.ExecResponse
+ (*ForkRequest)(nil), // 17: proto.ForkRequest
+ (*ForkResponse)(nil), // 18: proto.ForkResponse
+ (*RemoteAgentConfig)(nil), // 19: proto.RemoteAgentConfig
+ (*RegisterAgentRequest)(nil), // 20: proto.RegisterAgentRequest
+ (*RegisterAgentResponse)(nil), // 21: proto.RegisterAgentResponse
+ (*GeminiConfig)(nil), // 22: proto.GeminiConfig
+ nil, // 23: proto.RegisterAgentRequest.MetadataEntry
+ (*anypb.Any)(nil), // 24: google.protobuf.Any
+ (*structpb.Struct)(nil), // 25: google.protobuf.Struct
+ (*timestamppb.Timestamp)(nil), // 26: google.protobuf.Timestamp
+ (*durationpb.Duration)(nil), // 27: google.protobuf.Duration
}
var file_proto_ax_proto_depIdxs = []int32{
- 23, // 0: proto.AgentStart.config:type_name -> google.protobuf.Any
- 10, // 1: proto.AgentStart.contents:type_name -> proto.Content
- 10, // 2: proto.AgentOutputs.contents:type_name -> proto.Content
+ 24, // 0: proto.AgentStart.config:type_name -> google.protobuf.Any
+ 11, // 1: proto.AgentStart.messages:type_name -> proto.Message
+ 11, // 2: proto.AgentOutputs.messages:type_name -> proto.Message
1, // 3: proto.AgentMessage.start:type_name -> proto.AgentStart
2, // 4: proto.AgentMessage.outputs:type_name -> proto.AgentOutputs
5, // 5: proto.ConfirmationContent.approval:type_name -> proto.ApprovalDecision
6, // 6: proto.ConfirmationContent.decline:type_name -> proto.DeclineDecision
- 24, // 7: proto.FunctionCallContent.args:type_name -> google.protobuf.Struct
- 24, // 8: proto.FunctionResponseContent.response:type_name -> google.protobuf.Struct
+ 25, // 7: proto.FunctionCallContent.args:type_name -> google.protobuf.Struct
+ 25, // 8: proto.FunctionResponseContent.response:type_name -> google.protobuf.Struct
4, // 9: proto.Content.text:type_name -> proto.TextContent
7, // 10: proto.Content.confirmation:type_name -> proto.ConfirmationContent
8, // 11: proto.Content.function_call:type_name -> proto.FunctionCallContent
9, // 12: proto.Content.function_response:type_name -> proto.FunctionResponseContent
- 10, // 13: proto.ExecutionEvent.inputs:type_name -> proto.Content
- 10, // 14: proto.ExecutionEvent.outputs:type_name -> proto.Content
- 0, // 15: proto.ExecutionEvent.state:type_name -> proto.State
- 25, // 16: proto.ExecutionEvent.timestamp:type_name -> google.protobuf.Timestamp
- 23, // 17: proto.ExecRequest.agent_config:type_name -> google.protobuf.Any
- 10, // 18: proto.ExecRequest.inputs:type_name -> proto.Content
- 10, // 19: proto.ExecResponse.outputs:type_name -> proto.Content
- 22, // 20: proto.RegisterAgentRequest.metadata:type_name -> proto.RegisterAgentRequest.MetadataEntry
- 18, // 21: proto.RegisterAgentRequest.remote:type_name -> proto.RemoteAgentConfig
- 26, // 22: proto.GeminiConfig.timeout:type_name -> google.protobuf.Duration
- 3, // 23: proto.AgentService.Connect:input_type -> proto.AgentMessage
- 12, // 24: proto.AgentService.HealthCheck:input_type -> proto.HealthCheckRequest
- 14, // 25: proto.AXService.Exec:input_type -> proto.ExecRequest
- 16, // 26: proto.AXService.Fork:input_type -> proto.ForkRequest
- 19, // 27: proto.AXService.RegisterAgent:input_type -> proto.RegisterAgentRequest
- 3, // 28: proto.AgentService.Connect:output_type -> proto.AgentMessage
- 13, // 29: proto.AgentService.HealthCheck:output_type -> proto.HealthCheckResponse
- 15, // 30: proto.AXService.Exec:output_type -> proto.ExecResponse
- 17, // 31: proto.AXService.Fork:output_type -> proto.ForkResponse
- 20, // 32: proto.AXService.RegisterAgent:output_type -> proto.RegisterAgentResponse
- 28, // [28:33] is the sub-list for method output_type
- 23, // [23:28] is the sub-list for method input_type
- 23, // [23:23] is the sub-list for extension type_name
- 23, // [23:23] is the sub-list for extension extendee
- 0, // [0:23] is the sub-list for field type_name
+ 10, // 13: proto.Message.content:type_name -> proto.Content
+ 11, // 14: proto.ExecutionEvent.inputs:type_name -> proto.Message
+ 11, // 15: proto.ExecutionEvent.outputs:type_name -> proto.Message
+ 0, // 16: proto.ExecutionEvent.state:type_name -> proto.State
+ 26, // 17: proto.ExecutionEvent.timestamp:type_name -> google.protobuf.Timestamp
+ 24, // 18: proto.ExecRequest.agent_config:type_name -> google.protobuf.Any
+ 11, // 19: proto.ExecRequest.inputs:type_name -> proto.Message
+ 11, // 20: proto.ExecResponse.outputs:type_name -> proto.Message
+ 23, // 21: proto.RegisterAgentRequest.metadata:type_name -> proto.RegisterAgentRequest.MetadataEntry
+ 19, // 22: proto.RegisterAgentRequest.remote:type_name -> proto.RemoteAgentConfig
+ 27, // 23: proto.GeminiConfig.timeout:type_name -> google.protobuf.Duration
+ 3, // 24: proto.AgentService.Connect:input_type -> proto.AgentMessage
+ 13, // 25: proto.AgentService.HealthCheck:input_type -> proto.HealthCheckRequest
+ 15, // 26: proto.AXService.Exec:input_type -> proto.ExecRequest
+ 17, // 27: proto.AXService.Fork:input_type -> proto.ForkRequest
+ 20, // 28: proto.AXService.RegisterAgent:input_type -> proto.RegisterAgentRequest
+ 3, // 29: proto.AgentService.Connect:output_type -> proto.AgentMessage
+ 14, // 30: proto.AgentService.HealthCheck:output_type -> proto.HealthCheckResponse
+ 16, // 31: proto.AXService.Exec:output_type -> proto.ExecResponse
+ 18, // 32: proto.AXService.Fork:output_type -> proto.ForkResponse
+ 21, // 33: proto.AXService.RegisterAgent:output_type -> proto.RegisterAgentResponse
+ 29, // [29:34] is the sub-list for method output_type
+ 24, // [24:29] is the sub-list for method input_type
+ 24, // [24:24] is the sub-list for extension type_name
+ 24, // [24:24] is the sub-list for extension extendee
+ 0, // [0:24] is the sub-list for field type_name
}
func init() { file_proto_ax_proto_init() }
@@ -1628,7 +1677,7 @@ func file_proto_ax_proto_init() {
(*Content_FunctionCall)(nil),
(*Content_FunctionResponse)(nil),
}
- file_proto_ax_proto_msgTypes[18].OneofWrappers = []any{
+ file_proto_ax_proto_msgTypes[19].OneofWrappers = []any{
(*RegisterAgentRequest_Remote)(nil),
}
type x struct{}
@@ -1637,7 +1686,7 @@ func file_proto_ax_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_ax_proto_rawDesc), len(file_proto_ax_proto_rawDesc)),
NumEnums: 1,
- NumMessages: 22,
+ NumMessages: 23,
NumExtensions: 0,
NumServices: 2,
},
diff --git a/proto/ax.proto b/proto/ax.proto
index 03f7531..670bb68 100644
--- a/proto/ax.proto
+++ b/proto/ax.proto
@@ -26,11 +26,11 @@ option go_package = "github.com/google/ax/proto";
message AgentStart {
string agent_id = 1;
google.protobuf.Any config = 2;
- repeated Content contents = 3;
+ repeated Message messages = 3;
}
message AgentOutputs {
- repeated Content contents = 1;
+ repeated Message messages = 1;
string checkpoint_id = 2;
// TODO: Add awaiting_more field.
}
@@ -85,7 +85,7 @@ message FunctionResponseContent {
}
-// Content represents a message with role, type, mimetype, and data fields
+// Content represents a content input or output.
message Content {
reserved 1 to 4, 6 to 9, 11 to 25;
@@ -96,20 +96,24 @@ message Content {
FunctionResponseContent function_response = 28;
}
- string role = 1000; // The role of the content (e.g., "user", "assistant", "system")
-
// TODO: Bring other types to the oneof to be
// fully compatible with the Interactions Content message.
}
+// Message is a message in the history.
+message Message {
+ string role = 1; // user, assistant, or model
+ Content content = 2; // content of the message
+}
+
// ExecutionEvent is the entry in the event log. ExecutionEvents are used
// to record the actions taken place in the executor.
// The executor can replay the events for resumability.
message ExecutionEvent {
string exec_id = 1;
string agent_id = 2;
- repeated Content inputs = 3;
- repeated Content outputs = 4;
+ repeated Message inputs = 3;
+ repeated Message outputs = 4;
State state = 5;
google.protobuf.Timestamp timestamp = 6;
// string checkpoint_id = 10;
@@ -146,12 +150,12 @@ message ExecRequest {
string id = 1; // Unique execution identifier
string agent_id = 2; // Agent ID, if empty planner is used
google.protobuf.Any agent_config = 3; // Agent configuration if any
- repeated Content inputs = 4; // Input content to process
+ repeated Message inputs = 4; // Input content to process
}
// ExecResponse contains the result of an execution.
message ExecResponse {
- repeated Content outputs = 1; // Output content
+ repeated Message outputs = 1; // Output content
}
message ForkRequest {