Agent Executor (AX) is Google's open agentic orchestration runtime
Go
Add conversation_id in AgentMessage and Agent interface. (#244)
Junjie Wanga6d8a2803fdc
diff --git a/examples/k8s_sandbox_agent/main.go b/examples/k8s_sandbox_agent/main.goindex a40236a..b8dc9a7 100644--- a/examples/k8s_sandbox_agent/main.go+++ b/examples/k8s_sandbox_agent/main.go@@ -95,7 +95,8 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, proif len(outputs) > 0 {// Send response back via gRPCif err := stream.Send(&proto.AgentMessage{- ExecId: req.ExecId,+ ConversationId: req.ConversationId,+ ExecId: req.ExecId,Type: &proto.AgentMessage_Outputs{Outputs: &proto.AgentOutputs{Messages: outputs,@@ -108,7 +109,8 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, pro// Send AgentEnd to signal end of outputs.if err := stream.Send(&proto.AgentMessage{- ExecId: req.ExecId,+ ConversationId: req.ConversationId,+ ExecId: req.ExecId,Type: &proto.AgentMessage_End{End: &proto.AgentEnd{},},diff --git a/internal/agent/agent.go b/internal/agent/agent.goindex 1ee69a2..99eb696 100644--- a/internal/agent/agent.go+++ b/internal/agent/agent.go@@ -27,7 +27,7 @@ import (type OutputHandler func(outgoing *proto.AgentOutputs) errortype Executor interface {- Exec(ctx context.Context, execID string, start *proto.AgentStart, o OutputHandler) (proto.State, error)+ Exec(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, o OutputHandler) (proto.State, error)}// Agent defines the common interface for both local and remote agents.@@ -36,7 +36,7 @@ type Agent interface {// Connect handles processing of input content.// It calls the output handler for each piece of content generated.// The handler may be called multiple times during processing.- Connect(ctx context.Context, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error+ Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error// Close gracefully shuts down the agent and releases resources.Close() errordiff --git a/internal/agent/ate.go b/internal/agent/ate.goindex 02dec07..0849b18 100644--- a/internal/agent/ate.go+++ b/internal/agent/ate.go@@ -55,7 +55,7 @@ func NewATEAgent(endpoint string, config ATEAgentConfig) (*ATEAgent, error) {}// Connect handles processing of input content by creating an actor and delegating to RemoteAgent.-func (a *ATEAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error {+func (a *ATEAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error {// 1. Create Actorresp, err := a.ateClient.CreateActor(ctx, execID)if err != nil {@@ -97,7 +97,7 @@ func (a *ATEAgent) Connect(ctx context.Context, execID string, start *proto.Agen}}()- return remoteAgent.Connect(ctx, execID, start, e, o)+ return remoteAgent.Connect(ctx, conversationID, execID, start, e, o)}// Close gracefully shuts down the ATE agent connection.diff --git a/internal/agent/colab.go b/internal/agent/colab.goindex 15cecc5..9513114 100644--- a/internal/agent/colab.go+++ b/internal/agent/colab.go@@ -157,7 +157,7 @@ const (// the agent code, and tears the session down. If the session is terminated// due to idle timeout (e.g. while the user is authorizing Drive access),// it automatically recreates the session and retries once.-func (a *ColabAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error {+func (a *ColabAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error {sessionName := colabSessionName(a.config.ID, execID)for attempt := 0; attempt <= maxRetries; attempt++ {@@ -342,8 +342,6 @@ func (a *ColabAgent) isSessionAlive(ctx context.Context, sessionName string) booreturn err == nil}--// Close stops all currently active Colab sessions. This handles the case where// Close() is called (e.g. via SIGINT) while one or more Connect() calls are// mid-execution. In ax serve mode, multiple concurrent Connect() calls maydiff --git a/internal/agent/colab_test.go b/internal/agent/colab_test.goindex 2fc1f3e..a4b1051 100644--- a/internal/agent/colab_test.go+++ b/internal/agent/colab_test.go@@ -214,7 +214,7 @@ func TestConnect_FullSequence(t *testing.T) {Messages: []*proto.Message{userText("hello world")},}- if err := setup.agent.Connect(context.Background(), "exec-123", start, nil, handler); err != nil {+ if err := setup.agent.Connect(context.Background(), "test-conv", "exec-123", start, nil, handler); err != nil {t.Fatalf("Connect: %v", err)}@@ -255,7 +255,7 @@ func TestConnect_SessionCreationFails(t *testing.T) {t.Setenv("COLAB_FAIL_CMD", "new")start := &proto.AgentStart{Messages: []*proto.Message{userText("test")}}- err := setup.agent.Connect(context.Background(), "e1", start, nil, noopHandler)+ err := setup.agent.Connect(context.Background(), "test-conv", "e1", start, nil, noopHandler)if err == nil || !strings.Contains(err.Error(), "failed to create colab session") {t.Fatalf("want session creation error, got: %v", err)}@@ -273,7 +273,7 @@ func TestConnect_ExecFailure(t *testing.T) {t.Setenv("COLAB_FAIL_CMD", "exec")start := &proto.AgentStart{Messages: []*proto.Message{userText("test")}}- err := setup.agent.Connect(context.Background(), "e1", start, nil, noopHandler)+ err := setup.agent.Connect(context.Background(), "test-conv", "e1", start, nil, noopHandler)if err == nil {t.Fatal("expected error when exec fails")}@@ -293,7 +293,7 @@ func TestConnect_NotebookLocalFile(t *testing.T) {t.Setenv("COLAB_EXEC_STDOUT", "analysis complete")start := &proto.AgentStart{Messages: []*proto.Message{userText("analyze data")}}- if err := setup.agent.Connect(context.Background(), "e1", start, nil, noopHandler); err != nil {+ if err := setup.agent.Connect(context.Background(), "test-conv", "e1", start, nil, noopHandler); err != nil {t.Fatalf("Connect: %v", err)}@@ -324,7 +324,7 @@ func TestConnect_NotebookDriveFile(t *testing.T) {t.Setenv("COLAB_EXEC_STDOUT", "done")start := &proto.AgentStart{Messages: []*proto.Message{userText("analyze trends")}}- if err := setup.agent.Connect(context.Background(), "e1", start, nil, noopHandler); err != nil {+ if err := setup.agent.Connect(context.Background(), "test-conv", "e1", start, nil, noopHandler); err != nil {t.Fatalf("Connect: %v", err)}@@ -372,7 +372,7 @@ func TestConnect_RetryOnSessionTimeout(t *testing.T) {})start := &proto.AgentStart{Messages: []*proto.Message{userText("test")}}- if err := agent.Connect(context.Background(), "e1", start, nil, handler); err != nil {+ if err := agent.Connect(context.Background(), "test-conv", "e1", start, nil, handler); err != nil {t.Fatalf("Connect should succeed after retry: %v", err)}if output != "success on retry" {diff --git a/internal/agent/k8s_sandbox.go b/internal/agent/k8s_sandbox.goindex e11d333..5584124 100644--- a/internal/agent/k8s_sandbox.go+++ b/internal/agent/k8s_sandbox.go@@ -76,7 +76,7 @@ func newKubernetesSandboxAgentWithClient(ctx context.Context, client *sandboxclireturn agent, nil}-func (a *KubernetesSandboxAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error {+func (a *KubernetesSandboxAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error {ctx, cancel := context.WithTimeout(ctx, 5*time.Second)defer cancel()@@ -188,7 +188,7 @@ func (a *KubernetesSandboxAgent) Connect(ctx context.Context, execID string, stadefer remoteAgent.Close()// Forward the request!- return remoteAgent.Connect(ctx, execID, start, e, o)+ return remoteAgent.Connect(ctx, conversationID, execID, start, e, o)}func findAvailablePort() (int, error) {diff --git a/internal/agent/local.go b/internal/agent/local.goindex 40e2759..a7ec027 100644--- a/internal/agent/local.go+++ b/internal/agent/local.go@@ -25,12 +25,12 @@ import (// LocalAgent wraps a local (in-process) agent implementation.// It implements the Agent interface for agents running in the same process as the controller.type LocalAgent struct {- processFunc func(ctx context.Context, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error+ processFunc func(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error}// LocalAgentConfig configures a local agent.type LocalAgentConfig struct {- ProcessFunc func(ctx context.Context, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error+ ProcessFunc func(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error}// NewLocalAgent creates a new local agent with the provided configuration.@@ -40,13 +40,13 @@ func NewLocalAgent(config LocalAgentConfig) (*LocalAgent, error) {}return &LocalAgent{- processFunc: config.ProcessFunc,+ processFunc: config.ProcessFunc,}, nil}// Connect handles processing of input content with callback handler.-func (a *LocalAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error {- return a.processFunc(ctx, execID, start, e, o)+func (a *LocalAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error {+ return a.processFunc(ctx, conversationID, execID, start, e, o)}// Close gracefully shuts down the agent.diff --git a/internal/agent/remote.go b/internal/agent/remote.goindex ece44ba..9046612 100644--- a/internal/agent/remote.go+++ b/internal/agent/remote.go@@ -65,7 +65,7 @@ func (a *RemoteAgent) connect() (*grpc.ClientConn, error) {}// Connect handles processing of input content with the remote agent.-func (a *RemoteAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error {+func (a *RemoteAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e Executor, o OutputHandler) error {ctx = metadata.AppendToOutgoingContext(ctx, "execution-id", execID)conn, err := a.connect()@@ -81,7 +81,8 @@ func (a *RemoteAgent) Connect(ctx context.Context, execID string, start *proto.A}if err := stream.Send(&proto.AgentMessage{- ExecId: execID,+ ConversationId: conversationID,+ ExecId: execID,Type: &proto.AgentMessage_Start{Start: start,},@@ -109,6 +110,9 @@ func (a *RemoteAgent) Connect(ctx context.Context, execID string, start *proto.Acase *proto.AgentMessage_Start:return errors.New("starting new executions from remote agents is not supported yet")case *proto.AgentMessage_Outputs:+ if resp.ConversationId != conversationID {+ return fmt.Errorf("received outputs for different conversation id: %s != %s", resp.ConversationId, conversationID)+ }if resp.ExecId != execID {return fmt.Errorf("received outputs for different execution id: %s != %s", resp.ExecId, execID)}@@ -116,6 +120,9 @@ func (a *RemoteAgent) Connect(ctx context.Context, execID string, start *proto.Areturn fmt.Errorf("handler error: %w", err)}case *proto.AgentMessage_End:+ if resp.ConversationId != conversationID {+ return fmt.Errorf("received end for different conversation id: %s != %s", resp.ConversationId, conversationID)+ }if resp.ExecId != execID {return fmt.Errorf("received end for different execution id: %s != %s", resp.ExecId, execID)}diff --git a/internal/controller/antigravity_planner.go b/internal/controller/antigravity_planner.goindex 5e004bd..4ae76b9 100644--- a/internal/controller/antigravity_planner.go+++ b/internal/controller/antigravity_planner.go@@ -58,8 +58,8 @@ func NewAntigravityPlannerAgent(ctx context.Context, registry *Registry, cfg Antreturn nil, fmt.Errorf("failed to parse duration %q: %w", timeoutStr, err)}return &AntigravityPlannerAgent{- registry: registry,- config: cfg,+ registry: registry,+ config: cfg,httpClient: &http.Client{Timeout: timeout,},@@ -67,12 +67,12 @@ func NewAntigravityPlannerAgent(ctx context.Context, registry *Registry, cfg Ant}// Connect starts the agent loop.-func (p *AntigravityPlannerAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {- return p.loop(ctx, execID, start, e, handler)+func (p *AntigravityPlannerAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {+ return p.loop(ctx, conversationID, execID, start, e, handler)}// loop is the main execution loop for the Antigravity planner.-func (p *AntigravityPlannerAgent) loop(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {+func (p *AntigravityPlannerAgent) loop(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {payload, err := p.preparePayload(execID, start)if err != nil {return errdiff --git a/internal/controller/controller.go b/internal/controller/controller.goindex b82a238..5f93ded 100644--- a/internal/controller/controller.go+++ b/internal/controller/controller.go@@ -234,7 +234,7 @@ func (d *Controller) execute(ctx context.Context, conversationID string, execID}); err != nil {return err}- state, err := e.Exec(ctx, execID, &proto.AgentStart{+ state, err := e.Exec(ctx, conversationID, execID, &proto.AgentStart{AgentId: agentID,Config: agentConfig,Messages: append(history, newInputs...),diff --git a/internal/controller/controller_test.go b/internal/controller/controller_test.goindex 06a22ea..f01f616 100644--- a/internal/controller/controller_test.go+++ b/internal/controller/controller_test.go@@ -26,11 +26,11 @@ import (type dummyAgent struct{}-func (a *dummyAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {+func (a *dummyAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {return nil}-func (a *dummyAgent) Close() error { return nil }+func (a *dummyAgent) Close() error { return nil }func TestController_Exec_ResumptionAndIDGeneration(t *testing.T) {ctx := context.Background()@@ -221,7 +221,7 @@ func TestController_Exec_LastSeq(t *testing.T) {err = c.Exec(ctx, &proto.ExecRequest{ConversationId: cid,- LastSeq: 1,+ LastSeq: 1,}, handler)if err != nil {t.Fatal(err)@@ -320,7 +320,7 @@ func TestController_Exec_InternalOnly(t *testing.T) {// Create an agent that emits one internal-only message and one regular message.a := &mockAgentFunc{- connectFunc: func(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {+ connectFunc: func(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {// If we already have the public message in history, don't emit anything.for _, m := range start.Messages {if m.GetContent().GetText().GetText() == "public message" {@@ -386,7 +386,7 @@ func TestController_Exec_InternalOnly(t *testing.T) {if len(log.AllEvents) != 3 {t.Fatalf("expected 3 events in log.AllEvents, got %d", len(log.AllEvents))}-+// Event 0: Inputs// Event 1: Public messageif log.AllEvents[1].Messages[0].GetContent().GetText().GetText() != "public message" {@@ -397,7 +397,7 @@ func TestController_Exec_InternalOnly(t *testing.T) {if len(log.AllExecEvents) != 3 {t.Fatalf("expected 3 events in log.AllExecEvents, got %d", len(log.AllExecEvents))}-+// Event 1 in execEvents should contain both outputs.outputs := log.AllExecEvents[1].Outputsif len(outputs) != 2 {@@ -432,7 +432,7 @@ func TestController_Exec_InternalOnly(t *testing.T) {err = c2.Exec(ctx, &proto.ExecRequest{ConversationId: cid,- LastSeq: 1,+ LastSeq: 1,}, resumedHandler)if err != nil {t.Fatal(err)@@ -447,12 +447,11 @@ func TestController_Exec_InternalOnly(t *testing.T) {}type mockAgentFunc struct {- connectFunc func(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error+ connectFunc func(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error}-func (m *mockAgentFunc) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {- return m.connectFunc(ctx, execID, start, e, o)+func (m *mockAgentFunc) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {+ return m.connectFunc(ctx, conversationID, execID, start, e, o)}-func (m *mockAgentFunc) Close() error { return nil }-+func (m *mockAgentFunc) Close() error { return nil }diff --git a/internal/controller/executor/executor.go b/internal/controller/executor/executor.goindex ffa4bed..c5f5a26 100644--- a/internal/controller/executor/executor.go+++ b/internal/controller/executor/executor.go@@ -48,7 +48,7 @@ func DefaultExecutor(eventLog EventLog, registry map[string]agent.Agent) agent.E}}-func (tm *defaultExecutor) Exec(ctx context.Context, execID string, start *proto.AgentStart, o agent.OutputHandler) (proto.State, error) {+func (tm *defaultExecutor) Exec(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, o agent.OutputHandler) (proto.State, error) {execID = newExecID(tm.execID, execID)a, ok := tm.registry[start.AgentId]if !ok {@@ -78,11 +78,12 @@ func (tm *defaultExecutor) Exec(ctx context.Context, execID string, start *protoif state == proto.State_STATE_COMPLETED {return proto.State_STATE_COMPLETED, nil}- return tm.exec(ctx, execID, start, tm.eventLog, a, allInputs, o)+ return tm.exec(ctx, conversationID, execID, start, tm.eventLog, a, allInputs, o)}func (tm *defaultExecutor) exec(ctx context.Context,+ conversationID string,execID string,start *proto.AgentStart,el EventLog,@@ -113,7 +114,7 @@ func (tm *defaultExecutor) exec(}start.Messages = history- if err := a.Connect(ctx, execID, start, child, outputBuffer); err != nil {+ if err := a.Connect(ctx, conversationID, execID, start, child, outputBuffer); err != nil {// _ = logFailed(ctx, el, execID, start) // Attempt to log failure, but prioritize returning the original error.return proto.State_STATE_UNSPECIFIED, err}diff --git a/internal/controller/executor/executor_test.go b/internal/controller/executor/executor_test.goindex b3a2f94..79f44a4 100644--- a/internal/controller/executor/executor_test.go+++ b/internal/controller/executor/executor_test.go@@ -40,14 +40,14 @@ func Example() {registry := map[string]agent.Agent{"planner": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {- if _, err := tm.Exec(ctx, "deep-research-task", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "deep-research-task", &proto.AgentStart{AgentId: "deep-research",Messages: inputs,}, o); err != nil {return}- if _, err := tm.Exec(ctx, "pub-med-lookup-task", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "pub-med-lookup-task", &proto.AgentStart{AgentId: "pub-med-index",Messages: inputs,}, o); err != nil {@@ -57,7 +57,7 @@ func Example() {}tm := DefaultExecutor(memoryEventLog(), registry)- if _, err := tm.Exec(ctx, "test", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "test", &proto.AgentStart{AgentId: "planner",Messages: []*proto.Message{text("user", "Hello, I'd like to research cancer treatment options.")},}, nil); err != nil {@@ -70,7 +70,7 @@ func TestTaskManager(t *testing.T) {registry := map[string]agent.Agent{"root": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {- if _, err := tm.Exec(ctx, "child-task", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "child-task", &proto.AgentStart{AgentId: "child",Messages: inputs,}, o); err != nil {@@ -93,7 +93,7 @@ func TestTaskManager(t *testing.T) {}tm := DefaultExecutor(memoryEventLog(), registry)- if _, err := tm.Exec(ctx, "root-task", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "root-task", &proto.AgentStart{AgentId: "root",Messages: []*proto.Message{text("user", "hello!")},}, nil); err != nil {@@ -111,7 +111,7 @@ func TestFanout(t *testing.T) {for i := range 50 {i := i // Capture loop variable.g.Go(func() error {- _, err := tm.Exec(ctx, fmt.Sprintf("child-%d", i), &proto.AgentStart{+ _, err := tm.Exec(ctx, "test-conv", fmt.Sprintf("child-%d", i), &proto.AgentStart{AgentId: "child",Messages: inputs,}, nil)@@ -135,7 +135,7 @@ func TestFanout(t *testing.T) {for i := range 2 {i := i // Capture loop variable.g.Go(func() error {- _, err := tm.Exec(ctx, fmt.Sprintf("child2-%d", i), &proto.AgentStart{+ _, err := tm.Exec(ctx, "test-conv", fmt.Sprintf("child2-%d", i), &proto.AgentStart{AgentId: "child2",Messages: inputs,}, nil)@@ -163,7 +163,7 @@ func TestFanout(t *testing.T) {}tm := DefaultExecutor(memoryEventLog(), registry)- if _, err := tm.Exec(ctx, "root-task", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "root-task", &proto.AgentStart{AgentId: "root",Messages: []*proto.Message{text("user", "hello!")},}, nil); err != nil {@@ -185,7 +185,7 @@ func TestConfirmation(t *testing.T) {var childDone atomic.Boolregistry := map[string]agent.Agent{"root": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {- if _, err := tm.Exec(ctx, "child-task", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "child-task", &proto.AgentStart{AgentId: "child",Messages: inputs,}, o); err != nil {@@ -228,7 +228,7 @@ func TestConfirmation(t *testing.T) {tm := DefaultExecutor(eventLog, registry)// First run: child returns a confirmation request.- if _, err := tm.Exec(ctx, "root-task", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "root-task", &proto.AgentStart{AgentId: "root",Messages: []*proto.Message{text("user", "hello!")},}, nil); err != nil {@@ -249,7 +249,7 @@ func TestConfirmation(t *testing.T) {},},}- if _, err := tm.Exec(ctx, "root-task", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "root-task", &proto.AgentStart{AgentId: "root",Messages: []*proto.Message{approval},}, nil); err != nil {@@ -267,7 +267,7 @@ func TestResume(t *testing.T) {registry := map[string]agent.Agent{"root": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {- if _, err := tm.Exec(ctx, "child-task", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "child-task", &proto.AgentStart{AgentId: "child",Messages: inputs,}, nil); err != nil {@@ -290,7 +290,7 @@ func TestResume(t *testing.T) {}tm := DefaultExecutor(eventLog, registry)- if _, err := tm.Exec(ctx, "root-task", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "root-task", &proto.AgentStart{AgentId: "root",Messages: []*proto.Message{text("user", "hello!")},}, nil); err != nil {@@ -313,7 +313,7 @@ func TestResumeAgentIDMismatch(t *testing.T) {tm := DefaultExecutor(eventLog, registry)// First run: starts as "root"- if _, err := tm.Exec(ctx, "task1", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "task1", &proto.AgentStart{AgentId: "root",Messages: []*proto.Message{text("user", "hello!")},}, nil); err != nil {@@ -321,7 +321,7 @@ func TestResumeAgentIDMismatch(t *testing.T) {}// Second run: attempts to resume as "other" for same execID "task1"- _, err := tm.Exec(ctx, "task1", &proto.AgentStart{+ _, err := tm.Exec(ctx, "test-conv", "task1", &proto.AgentStart{AgentId: "other",Messages: []*proto.Message{text("user", "hello again!")},}, nil)@@ -393,7 +393,7 @@ func TestResumeConfirmation(t *testing.T) {tm := DefaultExecutor(eventLog, registry)// First run: starts as "root"- if _, err := tm.Exec(ctx, "task1", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "task1", &proto.AgentStart{AgentId: "root",Messages: []*proto.Message{text("user", "hello!")},}, nil); err != nil {@@ -406,7 +406,7 @@ func TestResumeConfirmation(t *testing.T) {return nil}// Second run: attempts to resume as "other" for same execID "task1"- if _, err := tm.Exec(ctx, "task1", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "task1", &proto.AgentStart{AgentId: "root",}, handler); err != nil {t.Fatal(err)@@ -424,7 +424,7 @@ func TestResumeConfirmation(t *testing.T) {msgs = outputs.Messagesreturn nil}- if _, err := tm.Exec(ctx, "task1", &proto.AgentStart{+ if _, err := tm.Exec(ctx, "test-conv", "task1", &proto.AgentStart{AgentId: "root",Messages: []*proto.Message{{diff --git a/internal/controller/executor/util.go b/internal/controller/executor/util.goindex fbad7ff..059774d 100644--- a/internal/controller/executor/util.go+++ b/internal/controller/executor/util.go@@ -24,12 +24,12 @@ import (// 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 {+func (f agentFunc) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, tm agent.Executor, o agent.OutputHandler) error {f(start.Messages, tm, o)return nil}-func (f agentFunc) Close() error { return nil }+func (f agentFunc) Close() error { return nil }func AgentFunc(fn func(input []*proto.Message, tm agent.Executor, o agent.OutputHandler)) agent.Agent {return agentFunc(fn)diff --git a/internal/controller/gemini.go b/internal/controller/gemini.goindex be4225d..c05e5a8 100644--- a/internal/controller/gemini.go+++ b/internal/controller/gemini.go@@ -54,7 +54,7 @@ func (a *GeminiAgent) config(start *proto.AgentStart) (*proto.GeminiConfig, erroreturn &cfg, nil}-func (a *GeminiAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {+func (a *GeminiAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {cfg, err := a.config(start)if err != nil {return errdiff --git a/internal/controller/gemini_planner.go b/internal/controller/gemini_planner.goindex 0dbcfa7..54962a8 100644--- a/internal/controller/gemini_planner.go+++ b/internal/controller/gemini_planner.go@@ -104,15 +104,15 @@ Guidelines:return p, nil}-func (p *geminiPlannerAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {- return p.loop(ctx, start, e, handler)+func (p *geminiPlannerAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {+ return p.loop(ctx, conversationID, start, e, handler)}func (p *geminiPlannerAgent) Close() error {return nil}-func (p *geminiPlannerAgent) loop(ctx context.Context, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) (err error) {+func (p *geminiPlannerAgent) loop(ctx context.Context, conversationID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) (err error) {var outputs []*proto.Messagevar outputCapturer = func(resp *proto.AgentOutputs) error {outputs = append(outputs, resp.Messages...)@@ -142,7 +142,7 @@ func (p *geminiPlannerAgent) loop(ctx context.Context, start *proto.AgentStart,Messages: append(start.Messages, outputs...),}outputs = nil- if _, err := e.Exec(ctx, nextAgentID, start, handler); err != nil {+ if _, err := e.Exec(ctx, conversationID, nextAgentID, start, handler); err != nil {return err}}diff --git a/internal/examples/ate_agent/main.go b/internal/examples/ate_agent/main.goindex 21936da..a653557 100644--- a/internal/examples/ate_agent/main.go+++ b/internal/examples/ate_agent/main.go@@ -60,7 +60,8 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, pro}if err := stream.Send(&proto.AgentMessage{- ExecId: incoming.ExecId,+ ConversationId: incoming.ConversationId,+ ExecId: incoming.ExecId,Type: &proto.AgentMessage_Outputs{Outputs: &proto.AgentOutputs{Messages: []*proto.Message{msg},@@ -72,7 +73,8 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, pro// Send AgentEnd to signal end of outputs.if err := stream.Send(&proto.AgentMessage{- ExecId: incoming.ExecId,+ ConversationId: incoming.ConversationId,+ ExecId: incoming.ExecId,Type: &proto.AgentMessage_End{End: &proto.AgentEnd{},},@@ -82,8 +84,6 @@ func (s *server) Connect(stream grpc.BidiStreamingServer[proto.AgentMessage, pro}}--func main() {fmt.Printf("Listening on port: %s\n", port)lis, err := net.Listen("tcp", port)diff --git a/internal/multi_test.go b/internal/multi_test.goindex 2f0ee30..9663cd7 100644--- a/internal/multi_test.go+++ b/internal/multi_test.go@@ -145,7 +145,7 @@ func TestMulti(t *testing.T) {}func createLocalAgent(transform func(string) string) (*agent.LocalAgent, error) {- processFunc := func(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {+ processFunc := func(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {for _, msg := range start.Messages {content := msg.GetContent()if content == nil {@@ -176,17 +176,17 @@ func createLocalAgent(transform func(string) string) (*agent.LocalAgent, error)}return agent.NewLocalAgent(agent.LocalAgentConfig{- ProcessFunc: processFunc,+ ProcessFunc: processFunc,})}type mockPlanner struct{}-func (m *mockPlanner) ID() string { return "__planner" }-func (m *mockPlanner) Name() string { return "Mock Planner" }+func (m *mockPlanner) ID() string { return "__planner" }+func (m *mockPlanner) Name() string { return "Mock Planner" }-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 {+func (m *mockPlanner) Close() error { return nil }+func (m *mockPlanner) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error {var lastText stringfor _, m := range start.Messages {if textMsg := m.GetContent().GetText(); textMsg != nil {@@ -204,7 +204,7 @@ func (m *mockPlanner) Connect(ctx context.Context, execID string, start *proto.A},},})- _, err := e.Exec(ctx, "local-echo", &proto.AgentStart{+ _, err := e.Exec(ctx, conversationID, "local-echo", &proto.AgentStart{AgentId: "local-echo-agent",Messages: inputs,}, handler)@@ -221,7 +221,7 @@ func (m *mockPlanner) Connect(ctx context.Context, execID string, start *proto.A},},})- _, err := e.Exec(ctx, "remote-text", &proto.AgentStart{+ _, err := e.Exec(ctx, conversationID, "remote-text", &proto.AgentStart{AgentId: "remote-text-processor",Messages: inputs,}, handler)@@ -238,7 +238,7 @@ func (m *mockPlanner) Connect(ctx context.Context, execID string, start *proto.A},},})- _, err := e.Exec(ctx, "uppercase-task", &proto.AgentStart{+ _, err := e.Exec(ctx, conversationID, "uppercase-task", &proto.AgentStart{AgentId: "uppercase",Messages: inputs,}, handler)diff --git a/internal/server/server_test.go b/internal/server/server_test.goindex 10afcf2..de183b7 100644--- a/internal/server/server_test.go+++ b/internal/server/server_test.go@@ -27,7 +27,7 @@ import (type dummyAgent struct{}-func (a *dummyAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {+func (a *dummyAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {return nil}func (a *dummyAgent) HealthCheck(ctx context.Context) error { return nil }diff --git a/internal/testagent/agent.go b/internal/testagent/agent.goindex 874965d..3a797fe 100644--- a/internal/testagent/agent.go+++ b/internal/testagent/agent.go@@ -46,7 +46,7 @@ func Agents() map[string]agent.Agent {type CodingAgent struct{}// Connect handles processing of input content with callback handler.-func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {+func (a *CodingAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {exec := NewExecutor(e, o)var history []*proto.Message@@ -64,7 +64,7 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.A},}inputs = append(inputs, start.Messages...)- outputs, err := exec.Exec(ctx, "code", &proto.AgentStart{+ outputs, err := exec.Exec(ctx, conversationID, "code", &proto.AgentStart{AgentId: "gemini",Messages: inputs,})@@ -75,7 +75,7 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.A}{- outputs, err := exec.Exec(ctx, "docker", &proto.AgentStart{+ outputs, err := exec.Exec(ctx, conversationID, "docker", &proto.AgentStart{AgentId: "docker-build",Messages: history,})@@ -92,7 +92,7 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.Aif err != nil {return err}- outputs, err := exec.Exec(ctx, "deploy", &proto.AgentStart{+ outputs, err := exec.Exec(ctx, conversationID, "deploy", &proto.AgentStart{AgentId: "kubernetes-deploy",Messages: history,Config: config,@@ -115,7 +115,7 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.Aif err != nil {return err}- outputs, err := exec.Exec(ctx, "deploy-more", &proto.AgentStart{+ outputs, err := exec.Exec(ctx, conversationID, "deploy-more", &proto.AgentStart{AgentId: "kubernetes-deploy",Messages: history,Config: config,@@ -156,7 +156,7 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.A},},})- _, err := exec.Exec(ctx, "summarize", &proto.AgentStart{+ _, err := exec.Exec(ctx, conversationID, "summarize", &proto.AgentStart{AgentId: "gemini",Messages: history,})@@ -176,7 +176,7 @@ var pendingRegions = make(map[string][]string) // not for productiontype KubernetesDeployAgent struct{}-func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {+func (a *KubernetesDeployAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {exec := NewExecutor(e, o)approved, conf := historyutil.HasConfirmationAnswer(start.Messages)@@ -203,7 +203,7 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, starfor _, region := range regions {if region != "us-central1" {- _, err := exec.Exec(ctx, "mirror-"+region, &proto.AgentStart{+ _, err := exec.Exec(ctx, conversationID, "mirror-"+region, &proto.AgentStart{AgentId: "docker-mirror",Messages: []*proto.Message{{@@ -299,8 +299,6 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star})}--// Close gracefully shuts down the agent.func (a *KubernetesDeployAgent) Close() error {return nil@@ -318,7 +316,7 @@ func NewExecutor(e agent.Executor, o agent.OutputHandler) *Executor {}}-func (e *Executor) Exec(ctx context.Context, execID string, start *proto.AgentStart) ([]*proto.Message, error) {+func (e *Executor) Exec(ctx context.Context, conversationID string, execID string, start *proto.AgentStart) ([]*proto.Message, error) {var outputs []*proto.Messageif execID == "" {var err error@@ -327,7 +325,7 @@ func (e *Executor) Exec(ctx context.Context, execID string, start *proto.AgentStreturn nil, err}}- if _, err := e.exec.Exec(ctx, execID, start, func(resp *proto.AgentOutputs) error {+ if _, err := e.exec.Exec(ctx, conversationID, execID, start, func(resp *proto.AgentOutputs) error {outputs = append(outputs, resp.Messages...)return e.handler(resp)}); err != nil {diff --git a/internal/testagent/docker.go b/internal/testagent/docker.goindex 5b797a2..f329469 100644--- a/internal/testagent/docker.go+++ b/internal/testagent/docker.go@@ -24,7 +24,7 @@ import (type DockerBuilderAgent struct{}-func (a *DockerBuilderAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {+func (a *DockerBuilderAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {o(&proto.AgentOutputs{Messages: []*proto.Message{{Role: "assistant",@@ -68,8 +68,6 @@ func (a *DockerBuilderAgent) Connect(ctx context.Context, execID string, start *return nil}--// Close gracefully shuts down the agent.func (a *DockerBuilderAgent) Close() error {return nil@@ -77,7 +75,7 @@ func (a *DockerBuilderAgent) Close() error {type DockerMirrorAgent struct{}-func (a *DockerMirrorAgent) Connect(ctx context.Context, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {+func (a *DockerMirrorAgent) Connect(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error {o(&proto.AgentOutputs{Messages: []*proto.Message{{Role: "assistant",diff --git a/internal/testagent/proto/testagent.pb.go b/internal/testagent/proto/testagent.pb.goindex fe12058..1b8e2d7 100644--- a/internal/testagent/proto/testagent.pb.go+++ b/internal/testagent/proto/testagent.pb.go@@ -15,7 +15,7 @@// Code generated by protoc-gen-go. DO NOT EDIT.// versions:// protoc-gen-go v1.36.11-// protoc v5.26.1+// protoc v7.34.0// source: internal/testagent/proto/testagent.protopackage protodiff --git a/proto/ax.pb.go b/proto/ax.pb.goindex 47390ce..c96436f 100644--- a/proto/ax.pb.go+++ b/proto/ax.pb.go@@ -15,7 +15,7 @@// Code generated by protoc-gen-go. DO NOT EDIT.// versions:// protoc-gen-go v1.36.11-// protoc v5.26.1+// protoc v7.34.0// source: proto/ax.protopackage proto@@ -243,8 +243,9 @@ func (*AgentEnd) Descriptor() ([]byte, []int) {}type AgentMessage struct {- state protoimpl.MessageState `protogen:"open.v1"`- ExecId string `protobuf:"bytes,1,opt,name=exec_id,json=execId,proto3" json:"exec_id,omitempty"`+ state protoimpl.MessageState `protogen:"open.v1"`+ ConversationId string `protobuf:"bytes,1,opt,name=conversation_id,json=conversationId,proto3" json:"conversation_id,omitempty"`+ ExecId string `protobuf:"bytes,2,opt,name=exec_id,json=execId,proto3" json:"exec_id,omitempty"`// Types that are valid to be assigned to Type://// *AgentMessage_Start@@ -285,6 +286,13 @@ func (*AgentMessage) Descriptor() ([]byte, []int) {return file_proto_ax_proto_rawDescGZIP(), []int{3}}+func (x *AgentMessage) GetConversationId() string {+ if x != nil {+ return x.ConversationId+ }+ return ""+}+func (x *AgentMessage) GetExecId() string {if x != nil {return x.ExecId@@ -331,15 +339,15 @@ type isAgentMessage_Type interface {}type AgentMessage_Start struct {- Start *AgentStart `protobuf:"bytes,2,opt,name=start,proto3,oneof"`+ Start *AgentStart `protobuf:"bytes,3,opt,name=start,proto3,oneof"`}type AgentMessage_Outputs struct {- Outputs *AgentOutputs `protobuf:"bytes,3,opt,name=outputs,proto3,oneof"`+ Outputs *AgentOutputs `protobuf:"bytes,4,opt,name=outputs,proto3,oneof"`}type AgentMessage_End struct {- End *AgentEnd `protobuf:"bytes,4,opt,name=end,proto3,oneof"`+ End *AgentEnd `protobuf:"bytes,5,opt,name=end,proto3,oneof"`}func (*AgentMessage_Start) isAgentMessage_Type() {}@@ -1343,12 +1351,13 @@ const file_proto_ax_proto_rawDesc = "" +"\bmessages\x18\x01 \x03(\v2\v.ax.MessageR\bmessages\x12#\n" +"\rinternal_only\x18\x02 \x01(\bR\finternalOnly\"\n" +"\n" +- "\bAgentEnd\"\xa7\x01\n" +- "\fAgentMessage\x12\x17\n" +- "\aexec_id\x18\x01 \x01(\tR\x06execId\x12&\n" +- "\x05start\x18\x02 \x01(\v2\x0e.ax.AgentStartH\x00R\x05start\x12,\n" +- "\aoutputs\x18\x03 \x01(\v2\x10.ax.AgentOutputsH\x00R\aoutputs\x12 \n" +- "\x03end\x18\x04 \x01(\v2\f.ax.AgentEndH\x00R\x03endB\x06\n" ++ "\bAgentEnd\"\xd0\x01\n" ++ "\fAgentMessage\x12'\n" ++ "\x0fconversation_id\x18\x01 \x01(\tR\x0econversationId\x12\x17\n" ++ "\aexec_id\x18\x02 \x01(\tR\x06execId\x12&\n" ++ "\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" +"\aMessage\x12\x12\n" +"\x04role\x18\x01 \x01(\tR\x04role\x12%\n" +diff --git a/proto/ax.proto b/proto/ax.protoindex d29d40e..34fbe78 100644--- a/proto/ax.proto+++ b/proto/ax.proto@@ -44,11 +44,12 @@ message AgentOutputs {message AgentEnd {}message AgentMessage {- string exec_id = 1;+ string conversation_id = 1;+ string exec_id = 2;oneof type {- AgentStart start = 2;- AgentOutputs outputs = 3;- AgentEnd end = 4;+ AgentStart start = 3;+ AgentOutputs outputs = 4;+ AgentEnd end = 5;}}diff --git a/proto/ax_grpc.pb.go b/proto/ax_grpc.pb.goindex 6c5aa3b..f22eac3 100644--- a/proto/ax_grpc.pb.go+++ b/proto/ax_grpc.pb.go@@ -15,7 +15,7 @@// Code generated by protoc-gen-go-grpc. DO NOT EDIT.// versions:// - protoc-gen-go-grpc v1.6.1-// - protoc v5.26.1+// - protoc v7.34.0// source: proto/ax.protopackage protodiff --git a/proto/content.pb.go b/proto/content.pb.goindex 0c840f1..42aa24a 100644--- a/proto/content.pb.go+++ b/proto/content.pb.go@@ -15,7 +15,7 @@// Code generated by protoc-gen-go. DO NOT EDIT.// versions:// protoc-gen-go v1.36.11-// protoc v5.26.1+// protoc v7.34.0// source: proto/content.protopackage proto