Skip to content

armgit / ax

Public Imported from GitHub
0

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

Go

Move internal_only to Message level. (#259)

Junjie Wang369b7fb88b6b
diff --git a/cmd/ax/trace.go b/cmd/ax/trace.go
index b2b5c18..7c924a6 100644
--- a/cmd/ax/trace.go
+++ b/cmd/ax/trace.go
@@ -203,6 +203,10 @@ func buildExecTraces(rootExecID string, execIDs []string, events []*proto.Execut
func extractMsgs(protoContents []*proto.Message) []Content {
var results []Content
for _, c := range protoContents {
+ // Skip messages flagged as internal-only.
+ if c.GetInternalOnly() {
+ continue
+ }
content := Content{Role: c.Role}
msgContent := c.GetContent()
if msgContent == nil {
diff --git a/internal/controller/controller.go b/internal/controller/controller.go
index c37f5c7..1ffcf69 100644
--- a/internal/controller/controller.go
+++ b/internal/controller/controller.go
@@ -207,13 +207,21 @@ func (d *Controller) Exec(ctx context.Context, req *proto.ExecRequest, handler E
func (d *Controller) execute(ctx context.Context, conversationID string, execID string, agentID string, agentConfig []byte, history []*proto.Message, newInputs []*proto.Message, registry map[string]agent.Agent, handler ExecHandler) error {
e := executor.DefaultExecutor(d.eventLog, registry)
outputCapturer := func(outgoing *proto.AgentOutputs) error {
- if outgoing.InternalOnly {
+ // Filter out internal-only messages.
+ var outputs []*proto.Message
+ for _, m := range outgoing.Messages {
+ if m.GetInternalOnly() {
+ continue
+ }
+ outputs = append(outputs, m)
+ }
+ if len(outputs) == 0 {
return nil
}
msg := &proto.ConversationEvent{
ConversationId: conversationID,
ExecId: execID,
- Messages: outgoing.Messages,
+ Messages: outputs,
State: proto.State_STATE_PENDING,
}
seq, err := d.eventLog.Append(ctx, msg)
diff --git a/internal/controller/controller_test.go b/internal/controller/controller_test.go
index f01f616..818630b 100644
--- a/internal/controller/controller_test.go
+++ b/internal/controller/controller_test.go
@@ -330,9 +330,12 @@ func TestController_Exec_InternalOnly(t *testing.T) {
// Emit internal-only message
if err := o(&proto.AgentOutputs{
Messages: []*proto.Message{
- {Role: "assistant", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "internal message"}}}},
+ {
+ Role: "assistant",
+ InternalOnly: true,
+ Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "internal message"}}},
+ },
},
- InternalOnly: true,
}); err != nil {
return err
}
diff --git a/internal/controller/gemini_planner.go b/internal/controller/gemini_planner.go
index 029aa29..bb83f79 100644
--- a/internal/controller/gemini_planner.go
+++ b/internal/controller/gemini_planner.go
@@ -327,6 +327,10 @@ func protoToContents(inputs []*proto.Message) []*genai.Content {
// Convert each message to Gemini format
for _, msg := range inputs {
+ // Skip internal messages.
+ if msg.GetInternalOnly() {
+ continue
+ }
role := msg.Role
if role != "user" {
role = "model"
diff --git a/proto/ax.pb.go b/proto/ax.pb.go
index 8b1a686..0ffa9c4 100644
--- a/proto/ax.pb.go
+++ b/proto/ax.pb.go
@@ -150,12 +150,8 @@ func (x *AgentStart) GetMessages() []*Message {
}
type AgentOutputs struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Messages []*Message `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
- // If true, these outputs are stored only in the execution log
- // (for resumption) and are not emitted to the client or stored
- // in the conversation history.
- InternalOnly bool `protobuf:"varint,2,opt,name=internal_only,json=internalOnly,proto3" json:"internal_only,omitempty"`
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Messages []*Message `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -197,13 +193,6 @@ func (x *AgentOutputs) GetMessages() []*Message {
return nil
}
-func (x *AgentOutputs) GetInternalOnly() bool {
- if x != nil {
- return x.InternalOnly
- }
- return false
-}
-
type AgentEnd struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
@@ -356,9 +345,13 @@ func (*AgentMessage_End) isAgentMessage_Type() {}
// 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
+ 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
+ // If true, the message is stored only in the execution log
+ // (for resumption) but not in the conversation history,
+ // and not emitted to the client or any agent.
+ InternalOnly bool `protobuf:"varint,3,opt,name=internal_only,json=internalOnly,proto3" json:"internal_only,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -407,6 +400,13 @@ func (x *Message) GetContent() *Content {
return nil
}
+func (x *Message) GetInternalOnly() bool {
+ if x != nil {
+ return x.InternalOnly
+ }
+ return false
+}
+
// A conversation is the historical session that consist of
// a number of execution. A conversation cannot be continued
// before the last execution is completed or failed.
@@ -1267,10 +1267,9 @@ const file_proto_ax_proto_rawDesc = "" +
"AgentStart\x12\x19\n" +
"\bagent_id\x18\x01 \x01(\tR\aagentId\x12!\n" +
"\fagent_config\x18\x02 \x01(\fR\vagentConfig\x12'\n" +
- "\bmessages\x18\x03 \x03(\v2\v.ax.MessageR\bmessages\"\\\n" +
+ "\bmessages\x18\x03 \x03(\v2\v.ax.MessageR\bmessages\"7\n" +
"\fAgentOutputs\x12'\n" +
- "\bmessages\x18\x01 \x03(\v2\v.ax.MessageR\bmessages\x12#\n" +
- "\rinternal_only\x18\x02 \x01(\bR\finternalOnly\"\n" +
+ "\bmessages\x18\x01 \x03(\v2\v.ax.MessageR\bmessages\"\n" +
"\n" +
"\bAgentEnd\"\xd0\x01\n" +
"\fAgentMessage\x12'\n" +
@@ -1279,10 +1278,11 @@ const file_proto_ax_proto_rawDesc = "" +
"\x05start\x18\x03 \x01(\v2\x0e.ax.AgentStartH\x00R\x05start\x12,\n" +
"\aoutputs\x18\x04 \x01(\v2\x10.ax.AgentOutputsH\x00R\aoutputs\x12 \n" +
"\x03end\x18\x05 \x01(\v2\f.ax.AgentEndH\x00R\x03endB\x06\n" +
- "\x04type\"D\n" +
+ "\x04type\"i\n" +
"\aMessage\x12\x12\n" +
"\x04role\x18\x01 \x01(\tR\x04role\x12%\n" +
- "\acontent\x18\x02 \x01(\v2\v.ax.ContentR\acontent\"\xb1\x01\n" +
+ "\acontent\x18\x02 \x01(\v2\v.ax.ContentR\acontent\x12#\n" +
+ "\rinternal_only\x18\x03 \x01(\bR\finternalOnly\"\xb1\x01\n" +
"\x11ConversationEvent\x12'\n" +
"\x0fconversation_id\x18\x01 \x01(\tR\x0econversationId\x12\x10\n" +
"\x03seq\x18\x02 \x01(\x05R\x03seq\x12\x17\n" +
diff --git a/proto/ax.proto b/proto/ax.proto
index f50e736..a3e5f42 100644
--- a/proto/ax.proto
+++ b/proto/ax.proto
@@ -32,11 +32,6 @@ message AgentStart {
message AgentOutputs {
repeated Message messages = 1;
-
- // If true, these outputs are stored only in the execution log
- // (for resumption) and are not emitted to the client or stored
- // in the conversation history.
- bool internal_only = 2;
}
message AgentEnd {}
@@ -55,6 +50,10 @@ message AgentMessage {
message Message {
string role = 1; // user, assistant, or model
Content content = 2; // content of the message
+ // If true, the message is stored only in the execution log
+ // (for resumption) but not in the conversation history,
+ // and not emitted to the client or any agent.
+ bool internal_only = 3;
}
// A conversation is the historical session that consist of
diff --git a/proto/ax_grpc.pb.go b/proto/ax_grpc.pb.go
index 376d1e2..f2ee3ae 100644
--- a/proto/ax_grpc.pb.go
+++ b/proto/ax_grpc.pb.go
@@ -14,7 +14,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
-// - protoc-gen-go-grpc v1.6.0
+// - protoc-gen-go-grpc v1.6.1
// - protoc v7.34.1
// source: proto/ax.proto