Skip to content

armgit / ax

Public Imported from GitHub
0

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

Go

Resume from last_seen_seq (#184)

Jaana Doganf6b0df6317b5
diff --git a/README.md b/README.md
index 295f8b9..2a786af 100644
--- a/README.md
+++ b/README.md
@@ -72,19 +72,27 @@ ax exec --input "Can you list me this directory?"
ax exec --input "Can you list me this directory?" --config my-config.yaml
```
-You can continue an execution any time:
+You can continue a conversation any time:
```bash
ax exec --conversation d85a4b4e-c53b-4c84-b879-f10d905bce40 --input "Show me the contents of README.md"
```
+You can continue from a previous sequence if client got disconnected
+during an conversation. In this example, we skip seeing the events after
+sequence number 12:
+```bash
+ax exec --conversation d85a4b4e-c53b-4c84-b879-f10d905bce40 --resume --last-seen-seq 12
+```
+
Instead of running the default planner agent, you can run any registered agent:
```bash
ax exec --agent coding --input "Can you write me a simple HTTP server in Python?"
```
-You can resume an incomplete execution:
+If anything goes wrong during the execution of an agent,
+you can resume an incomplete execution in a conversation:
```bash
ax exec --resume --agent "coding" --conversation "edf98ef5-4bb1-4a9e-a091-3a77e03727e6"
```
diff --git a/cmd/ax/exec.go b/cmd/ax/exec.go
index 62e826d..5010195 100644
--- a/cmd/ax/exec.go
+++ b/cmd/ax/exec.go
@@ -24,7 +24,6 @@ import (
"syscall"
"github.com/google/ax/cmd/ax/internal"
- "github.com/google/ax/internal/agent"
"github.com/google/ax/internal/config"
"github.com/google/ax/internal/controller"
"github.com/google/ax/proto"
@@ -39,6 +38,7 @@ var (
execServerAddr string
execConfigFile string
execResume bool // allow resuming an execution without inputs
+ execLastSeenSeq int32
)
var execCmd = &cobra.Command{
@@ -56,6 +56,7 @@ func init() {
execCmd.Flags().StringVar(&execServerAddr, "server", "", "gRPC controller server address (if specified, connects to remote server; otherwise runs with a local built-in AX server)")
execCmd.Flags().StringVar(&execConfigFile, "config", "ax.yaml", "Path to YAML configuration file (only used with a local built-in AX server)")
execCmd.Flags().BoolVar(&execResume, "resume", false, "Resume a conversation without inputs")
+ execCmd.Flags().Int32Var(&execLastSeenSeq, "last-seen-seq", 0, "Last sequence number seen by the client")
execCmd.MarkFlagsMutuallyExclusive("input", "resume")
}
@@ -84,10 +85,10 @@ func runExec(cmd *cobra.Command, args []string) error {
cancel()
}()
- return execLoop(ctx, execConversationID, execAgentID, execInput)
+ return execLoop(ctx, execConversationID, execAgentID, execInput, execLastSeenSeq)
}
-func execLoop(ctx context.Context, id string, agentID string, input string) error {
+func execLoop(ctx context.Context, id string, agentID string, input string, lastSeq int32) error {
d := internal.NewDisplay(id)
d.DisplayHeader()
@@ -117,7 +118,13 @@ func execLoop(ctx context.Context, id string, agentID string, input string) erro
}
for {
- conf, err := runAutoExec(ctx, d, id, agentID, inputs)
+ conf, err := runAutoExec(ctx, d, &proto.ExecRequest{
+ ConversationId: id,
+ AgentId: agentID,
+ Inputs: inputs,
+ LastSeenSeq: lastSeq,
+ })
+ lastSeq = 0 // disable resuming from sequence, user sees the seq on the screen
if err != nil {
return err
}
@@ -159,7 +166,11 @@ func execLoop(ctx context.Context, id string, agentID string, input string) erro
}}
}
- conf, err = runAutoExec(ctx, d, id, agentID, decision)
+ conf, err = runAutoExec(ctx, d, &proto.ExecRequest{
+ ConversationId: id,
+ AgentId: agentID,
+ Inputs: decision,
+ })
if err != nil {
return err
}
@@ -194,15 +205,15 @@ func execLoop(ctx context.Context, id string, agentID string, input string) erro
}
}
-func runAutoExec(ctx context.Context, d *internal.Display, id string, agentID string, inputs []*proto.Message) (*proto.ConfirmationContent, error) {
+func runAutoExec(ctx context.Context, d *internal.Display, req *proto.ExecRequest) (*proto.ConfirmationContent, error) {
fn := runExecHeadless
if execServerAddr != "" {
fn = runExecServer
}
- return fn(ctx, d, id, agentID, inputs)
+ return fn(ctx, d, req)
}
-func runExecHeadless(ctx context.Context, d *internal.Display, id string, agentID string, inputs []*proto.Message) (*proto.ConfirmationContent, error) {
+func runExecHeadless(ctx context.Context, d *internal.Display, req *proto.ExecRequest) (*proto.ConfirmationContent, error) {
if execController == nil {
cfg, err := config.LoadFromFile(execConfigFile)
if err != nil {
@@ -217,30 +228,28 @@ func runExecHeadless(ctx context.Context, d *internal.Display, id string, agentI
}
var confirmation *proto.ConfirmationContent
- outputHandler := agent.OutputHandler(func(resp *proto.AgentOutputs) error {
- for _, m := range resp.Messages {
+ var lastSeq int32
+ outputHandler := controller.ExecHandler(func(resp *proto.ExecResponse) error {
+ for _, m := range resp.Outputs {
if conf := m.GetContent().GetConfirmation(); conf != nil {
confirmation = conf
}
}
- displayContents(d, resp.Messages)
+ lastSeq = resp.Seq
+ displayContents(d, resp.Outputs)
return nil
})
- if err := execController.Exec(ctx, &proto.ExecRequest{
- ConversationId: id,
- AgentId: agentID,
- Inputs: inputs,
- }, outputHandler); err != nil {
+ if err := execController.Exec(ctx, req, outputHandler); err != nil {
return nil, fmt.Errorf("error executing with local server: %w", err)
}
if confirmation == nil {
- d.FinishOutput("")
+ d.FinishOutput(fmt.Sprintf("seq=%d", lastSeq))
}
return confirmation, nil
}
-func runExecServer(ctx context.Context, d *internal.Display, id string, agentID string, inputs []*proto.Message) (*proto.ConfirmationContent, error) {
+func runExecServer(ctx context.Context, d *internal.Display, req *proto.ExecRequest) (*proto.ConfirmationContent, error) {
conn, err := connect(execServerAddr)
if err != nil {
return nil, err
@@ -248,17 +257,13 @@ func runExecServer(ctx context.Context, d *internal.Display, id string, agentID
defer conn.Close()
client := proto.NewAXServiceClient(conn)
- stream, err := client.Exec(ctx, &proto.ExecRequest{
- ConversationId: id,
- AgentId: agentID,
- Inputs: inputs,
- })
+ stream, err := client.Exec(ctx, req)
if err != nil {
return nil, fmt.Errorf("error executing: %w", err)
}
- var checkpoint string
var confirmation *proto.ConfirmationContent
+ var lastSeq int32
for {
resp, err := stream.Recv()
if err == io.EOF {
@@ -267,6 +272,7 @@ func runExecServer(ctx context.Context, d *internal.Display, id string, agentID
if err != nil {
return nil, fmt.Errorf("error receiving response: %w", err)
}
+ lastSeq = resp.Seq
if resp.Outputs != nil {
for _, m := range resp.Outputs {
if conf := m.GetContent().GetConfirmation(); conf != nil {
@@ -277,7 +283,7 @@ func runExecServer(ctx context.Context, d *internal.Display, id string, agentID
}
}
if confirmation == nil {
- d.FinishOutput(checkpoint)
+ d.FinishOutput(fmt.Sprintf("seq=%d", lastSeq))
}
return confirmation, nil
}
diff --git a/cmd/ax/internal/display.go b/cmd/ax/internal/display.go
index c974010..b9e91b5 100644
--- a/cmd/ax/internal/display.go
+++ b/cmd/ax/internal/display.go
@@ -66,16 +66,14 @@ func (d *Display) DisplayInput(text string) {
// DisplayOutput displays an output fragment.
func (d *Display) DisplayOutput(text string) {
- fmt.Print(text)
+ fmt.Println(text)
+ fmt.Println()
}
-// Finish completes the streaming output and shows checkpoint if provided
-func (d *Display) FinishOutput(checkpointID string) {
- fmt.Print("\n")
-
- // Show checkpoint box if checkpoint ID exists
- if checkpointID != "" {
- fmt.Println(d.checkpointStyle.Render("Checkpoint: " + checkpointID))
+// FinishOutput completes the streaming output and shows info if provided
+func (d *Display) FinishOutput(info string) {
+ if info != "" {
+ fmt.Println(d.checkpointStyle.Render(info))
}
fmt.Println()
}
diff --git a/internal/controller/controller.go b/internal/controller/controller.go
index 4dcda5a..edd59bf 100644
--- a/internal/controller/controller.go
+++ b/internal/controller/controller.go
@@ -36,6 +36,8 @@ import (
const plannerAgentID = "__planner"
+type ExecHandler func(resp *proto.ExecResponse) error
+
// Controller is the main controller that coordinates all components.
// It acts as a single-writer system for managing agentic loops.
type Controller struct {
@@ -88,7 +90,7 @@ func New(ctx context.Context, config Config) (*Controller, error) {
}, nil
}
-func (d *Controller) tryResuming(ctx context.Context, req *proto.ExecRequest, el executor.EventLog, registry map[string]agent.Agent, handler agent.OutputHandler) (history []*proto.Message, done bool, err error) {
+func (d *Controller) tryResuming(ctx context.Context, req *proto.ExecRequest, el executor.EventLog, registry map[string]agent.Agent, handler ExecHandler) (history []*proto.Message, done bool, err error) {
events, err := el.Events(ctx, req.ConversationId)
if err != nil {
return nil, false, fmt.Errorf("failed to retrieve execution history: %w", err)
@@ -104,6 +106,19 @@ func (d *Controller) tryResuming(ctx context.Context, req *proto.ExecRequest, el
history = append(history, ev.Messages...)
}
+ if req.LastSeenSeq != 0 {
+ for _, ev := range events {
+ if ev.Seq > req.LastSeenSeq {
+ if err := handler(&proto.ExecResponse{
+ Outputs: ev.Messages,
+ Seq: ev.Seq,
+ }); err != nil {
+ return nil, false, err
+ }
+ }
+ }
+ }
+
if pendingExecID == "" {
return history, false, nil
}
@@ -144,7 +159,7 @@ func (d *Controller) tryResuming(ctx context.Context, req *proto.ExecRequest, el
// Exec executes a new agentic loop execution or resumes an existing one.
// If id is empty, a UUID will be generated.
// If the execution already exists, it will be resumed with optional new inputs.
-func (d *Controller) Exec(ctx context.Context, req *proto.ExecRequest, handler agent.OutputHandler) error {
+func (d *Controller) Exec(ctx context.Context, req *proto.ExecRequest, handler ExecHandler) error {
if req.ConversationId == "" {
return fmt.Errorf("conversation_id is required")
}
@@ -197,14 +212,25 @@ func (d *Controller) Exec(ctx context.Context, req *proto.ExecRequest, handler a
)
}
-func (d *Controller) execute(ctx context.Context, conversationID string, execID string, agentID string, agentConfig *anypb.Any, history []*proto.Message, newInputs []*proto.Message, registry map[string]agent.Agent, handler agent.OutputHandler) error {
+func (d *Controller) execute(ctx context.Context, conversationID string, execID string, agentID string, agentConfig *anypb.Any, history []*proto.Message, newInputs []*proto.Message, registry map[string]agent.Agent, handler ExecHandler) error {
e := executor.DefaultExecutor(d.eventLog, registry)
- var outputs []*proto.Message
outputCapturer := func(outgoing *proto.AgentOutputs) error {
- outputs = append(outputs, outgoing.Messages...)
- return handler(outgoing)
+ msg := &proto.ConversationEvent{
+ ConversationId: conversationID,
+ ExecId: execID,
+ Messages: outgoing.Messages,
+ State: proto.State_STATE_PENDING,
+ }
+ seq, err := d.eventLog.Append(ctx, msg)
+ if err != nil {
+ return err
+ }
+ return handler(&proto.ExecResponse{
+ Outputs: msg.Messages,
+ Seq: seq,
+ })
}
- if err := d.eventLog.Append(ctx, &proto.ConversationEvent{
+ if _, err := d.eventLog.Append(ctx, &proto.ConversationEvent{
ConversationId: conversationID,
ExecId: execID,
Messages: newInputs,
@@ -220,12 +246,12 @@ func (d *Controller) execute(ctx context.Context, conversationID string, execID
if err != nil {
return err
}
- return d.eventLog.Append(ctx, &proto.ConversationEvent{
+ _, err = d.eventLog.Append(ctx, &proto.ConversationEvent{
ConversationId: conversationID,
ExecId: execID,
- Messages: outputs,
State: state,
})
+ return err
}
// Fork forks an execution from a source execution.
diff --git a/internal/controller/controller_test.go b/internal/controller/controller_test.go
index a83c264..002b412 100644
--- a/internal/controller/controller_test.go
+++ b/internal/controller/controller_test.go
@@ -30,9 +30,13 @@ type mockEventLog struct {
execEvents []*proto.ExecutionEvent
}
-func (m *mockEventLog) Append(ctx context.Context, event *proto.ConversationEvent) error {
+func (m *mockEventLog) Append(ctx context.Context, event *proto.ConversationEvent) (int32, error) {
+ m.mu.Lock()
+ defer m.mu.Unlock()
+ seq := int32(len(m.events) + 1)
+ event.Seq = seq
m.events = append(m.events, event)
- return nil
+ return seq, nil
}
func (m *mockEventLog) AppendExec(ctx context.Context, event *proto.ExecutionEvent) error {
@@ -159,3 +163,120 @@ func TestController_Exec_ResumptionAndIDGeneration(t *testing.T) {
t.Fatal("expected a NEW execution ID, but it was reused")
}
}
+
+
+func TestController_Exec_LastSeenSeq_Empty(t *testing.T) {
+ ctx := context.Background()
+ cid := "test-conv-seq"
+
+ log := &mockEventLog{}
+ // Pre-populate history
+ log.events = []*proto.ConversationEvent{
+ {
+ ConversationId: cid,
+ Seq: 1,
+ Messages: []*proto.Message{
+ {Role: "user", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 1"}}}},
+ },
+ State: proto.State_STATE_COMPLETED,
+ },
+ {
+ ConversationId: cid,
+ Seq: 2,
+ Messages: []*proto.Message{
+ {Role: "assistant", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 2"}}}},
+ },
+ State: proto.State_STATE_COMPLETED,
+ },
+ }
+
+ c, err := New(ctx, Config{
+ EventLogBuilder: func() (executor.EventLog, error) {
+ return log, nil
+ },
+ PlannerBuilder: func(ctx context.Context, r *Registry) (agent.Agent, error) {
+ return &dummyAgent{}, nil
+ },
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer c.Close()
+
+ var msgs []*proto.Message
+ handler := ExecHandler(func(resp *proto.ExecResponse) error {
+ msgs = append(msgs, resp.Outputs...)
+ return nil
+ })
+
+ err = c.Exec(ctx, &proto.ExecRequest{
+ ConversationId: cid,
+ }, handler)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(msgs) != 0 {
+ t.Fatalf("expected 0 messages, got %d", len(msgs))
+ }
+}
+
+func TestController_Exec_LastSeenSeq(t *testing.T) {
+ ctx := context.Background()
+ cid := "test-conv-seq"
+
+ log := &mockEventLog{}
+ // Pre-populate history
+ log.events = []*proto.ConversationEvent{
+ {
+ ConversationId: cid,
+ Seq: 1,
+ Messages: []*proto.Message{
+ {Role: "user", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 1"}}}},
+ },
+ State: proto.State_STATE_COMPLETED,
+ },
+ {
+ ConversationId: cid,
+ Seq: 2,
+ Messages: []*proto.Message{
+ {Role: "assistant", Content: &proto.Content{Content: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 2"}}}},
+ },
+ State: proto.State_STATE_COMPLETED,
+ },
+ }
+
+ c, err := New(ctx, Config{
+ EventLogBuilder: func() (executor.EventLog, error) {
+ return log, nil
+ },
+ PlannerBuilder: func(ctx context.Context, r *Registry) (agent.Agent, error) {
+ return &dummyAgent{}, nil
+ },
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer c.Close()
+
+ var msgs []*proto.Message
+ handler := ExecHandler(func(resp *proto.ExecResponse) error {
+ msgs = append(msgs, resp.Outputs...)
+ return nil
+ })
+
+ err = c.Exec(ctx, &proto.ExecRequest{
+ ConversationId: cid,
+ LastSeenSeq: 1,
+ }, handler)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // We expect to receive messages from Seq 2 (since LastSeenSeq is 1).
+ if len(msgs) != 1 {
+ t.Fatalf("expected 1 message, got %d", len(msgs))
+ }
+ if msgs[0].GetContent().GetText().GetText() != "msg 2" {
+ t.Fatalf("expected 'msg 2', got %v", msgs[0].GetContent().GetText().GetText())
+ }
+}
diff --git a/internal/controller/executor/eventlog.go b/internal/controller/executor/eventlog.go
index 5d9ca83..bd62aeb 100644
--- a/internal/controller/executor/eventlog.go
+++ b/internal/controller/executor/eventlog.go
@@ -26,7 +26,7 @@ import (
// the executor back to a consistent state from which execution can resume.
type EventLog interface {
// Append adds a conversation event to the end of the log.
- Append(ctx context.Context, event *proto.ConversationEvent) error
+ Append(ctx context.Context, event *proto.ConversationEvent) (int32, error)
// AppendExec adds an execution event to the end of the log.
AppendExec(ctx context.Context, event *proto.ExecutionEvent) error
diff --git a/internal/controller/executor/executor_test.go b/internal/controller/executor/executor_test.go
index a783563..cf69be9 100644
--- a/internal/controller/executor/executor_test.go
+++ b/internal/controller/executor/executor_test.go
@@ -38,12 +38,14 @@ type MemoryEventLog struct {
execEvents []*proto.ExecutionEvent
}
-func (m *MemoryEventLog) Append(_ context.Context, event *proto.ConversationEvent) error {
+func (m *MemoryEventLog) Append(_ context.Context, event *proto.ConversationEvent) (int32, error) {
m.mu.Lock()
defer m.mu.Unlock()
+ seq := int32(len(m.events) + 1)
+ event.Seq = seq
m.events = append(m.events, event)
- return nil
+ return seq, nil
}
func (m *MemoryEventLog) AppendExec(_ context.Context, event *proto.ExecutionEvent) error {
diff --git a/internal/controller/executor/sqlite.go b/internal/controller/executor/sqlite.go
index 57a31d5..e34921a 100644
--- a/internal/controller/executor/sqlite.go
+++ b/internal/controller/executor/sqlite.go
@@ -79,19 +79,19 @@ func OpenSQLiteEventLog(path string) (*SQLiteEventLog, error) {
}
// Append serializes the event to JSON and inserts it into the database.
-func (l *SQLiteEventLog) Append(ctx context.Context, event *proto.ConversationEvent) error {
+func (l *SQLiteEventLog) Append(ctx context.Context, event *proto.ConversationEvent) (int32, error) {
seq := event.Seq
if seq == 0 {
err := l.db.QueryRowContext(ctx, "SELECT COALESCE(MAX(seq), 0) + 1 FROM conversation_log WHERE conversation_id = ?", event.ConversationId).Scan(&seq)
if err != nil {
- return fmt.Errorf("sqlite_eventlog: compute seq: %w", err)
+ return 0, fmt.Errorf("sqlite_eventlog: compute seq: %w", err)
}
event.Seq = seq
}
payload, err := marshalOpts.Marshal(event)
if err != nil {
- return fmt.Errorf("sqlite_eventlog: marshal event: %w", err)
+ return 0, fmt.Errorf("sqlite_eventlog: marshal event: %w", err)
}
_, err = l.db.ExecContext(ctx,
@@ -99,10 +99,10 @@ func (l *SQLiteEventLog) Append(ctx context.Context, event *proto.ConversationEv
event.ConversationId, event.Seq, string(payload))
if err != nil {
- return fmt.Errorf("sqlite_eventlog: insert conversation: %w", err)
+ return 0, fmt.Errorf("sqlite_eventlog: insert conversation: %w", err)
}
- return nil
+ return seq, nil
}
// AppendExec inserts an execution event into the database.
diff --git a/internal/controller/executor/sqlite_test.go b/internal/controller/executor/sqlite_test.go
index 5b28031..91382e1 100644
--- a/internal/controller/executor/sqlite_test.go
+++ b/internal/controller/executor/sqlite_test.go
@@ -48,10 +48,10 @@ func TestSQLiteEventLog_AppendAndEvents(t *testing.T) {
ExecId: "task-2",
}
- if err := log.Append(ctx, cev1); err != nil {
+ if _, err := log.Append(ctx, cev1); err != nil {
t.Fatalf("failed to append cev1: %v", err)
}
- if err := log.Append(ctx, cev2); err != nil {
+ if _, err := log.Append(ctx, cev2); err != nil {
t.Fatalf("failed to append cev2: %v", err)
}
@@ -120,7 +120,7 @@ func TestSQLiteEventLog_ConcurrentAppend(t *testing.T) {
Seq: int32(agentIdx*numEvents + i + 1),
ExecId: "task-concurrent",
}
- if err := log.Append(ctx, ev); err != nil {
+ if _, err := log.Append(ctx, ev); err != nil {
t.Errorf("concurrent append failed: %v", err)
}
}
diff --git a/internal/controller/gemini.go b/internal/controller/gemini.go
index 411c7a7..975e4eb 100644
--- a/internal/controller/gemini.go
+++ b/internal/controller/gemini.go
@@ -517,7 +517,5 @@ func execute(args map[string]any) (string, error) {
if result == "" {
return "Command executed successfully (no output)", nil
}
- result = strings.TrimSpace(result) + "\n"
-
return result, nil
}
diff --git a/internal/server/server.go b/internal/server/server.go
index f23eaa2..2794ab7 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -26,7 +26,6 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
- "github.com/google/ax/internal/agent"
"github.com/google/ax/internal/config"
"github.com/google/ax/internal/controller"
"github.com/google/ax/proto"
@@ -50,10 +49,8 @@ func New(c *controller.Controller) *Server {
// Exec executes a new agentic task with streaming responses.
func (s *Server) Exec(req *proto.ExecRequest, stream grpc.ServerStreamingServer[proto.ExecResponse]) error {
// Create output handler to stream outputs back to client
- outputHandler := agent.OutputHandler(func(outgoing *proto.AgentOutputs) error {
- return stream.Send(&proto.ExecResponse{
- Outputs: outgoing.Messages,
- })
+ outputHandler := controller.ExecHandler(func(resp *proto.ExecResponse) error {
+ return stream.Send(resp)
})
return s.controller.Exec(stream.Context(), req, outputHandler)
}
diff --git a/internal/test_multi/test_multi.go b/internal/test_multi/test_multi.go
index 036aa02..ffca0d6 100644
--- a/internal/test_multi/test_multi.go
+++ b/internal/test_multi/test_multi.go
@@ -103,8 +103,8 @@ func main() {
log.Printf("ID: %s\n", execID)
- handler := agent.OutputHandler(func(outgoing *proto.AgentOutputs) error {
- for _, m := range outgoing.Messages {
+ handler := controller.ExecHandler(func(resp *proto.ExecResponse) error {
+ for _, m := range resp.Outputs {
if textContent := m.GetContent().GetText(); textContent != nil {
fmt.Printf("Output received: %s\n", textContent.Text)
}
diff --git a/internal/testagent/agent.go b/internal/testagent/agent.go
index 6080249..5503d42 100644
--- a/internal/testagent/agent.go
+++ b/internal/testagent/agent.go
@@ -30,6 +30,10 @@ import (
"google.golang.org/protobuf/types/known/anypb"
)
+// Please note that this is not production code. testagent is only for testing ax.
+// and it will be deleted once we have comprehensive agents and integration tests.
+// testagent is not meant to be used in production.
+
func Agents() map[string]agent.Agent {
return map[string]agent.Agent{
"coding": &CodingAgent{},
@@ -132,7 +136,7 @@ func (a *CodingAgent) Connect(ctx context.Context, execID string, start *proto.A
Content: &proto.Content{
Content: &proto.Content_Text{
Text: &proto.TextContent{
- Text: "One last step, a summary...\n\n",
+ Text: "One last step, a summary...",
},
},
},
@@ -193,7 +197,7 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
Content: &proto.Content{
Content: &proto.Content_Text{
Text: &proto.TextContent{
- Text: fmt.Sprintf("\nPicked %v region(s) for deployment.\n", strings.Join(regions, ",")),
+ Text: fmt.Sprintf("Picked %v region(s) for deployment.", strings.Join(regions, ",")),
},
},
},
@@ -229,7 +233,7 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
Content: &proto.Content{
Content: &proto.Content_Text{
Text: &proto.TextContent{
- Text: "* Deploying to " + region + ", this may take a while...\n",
+ Text: "* Deploying to " + region + ", this may take a while...",
},
},
},
@@ -243,7 +247,7 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
Content: &proto.Content{
Content: &proto.Content_Text{
Text: &proto.TextContent{
- Text: "* kubectl apply -f deployment.yaml\n",
+ Text: "* kubectl apply -f deployment.yaml",
},
},
},
@@ -259,7 +263,7 @@ func (a *KubernetesDeployAgent) Connect(ctx context.Context, execID string, star
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),
+ Text: fmt.Sprintf("* Deployment complete. You can access the service at https://%v.test.services.acme.com", region),
},
},
},
diff --git a/internal/testagent/docker.go b/internal/testagent/docker.go
index 499c6d9..3777c04 100644
--- a/internal/testagent/docker.go
+++ b/internal/testagent/docker.go
@@ -31,7 +31,7 @@ func (a *DockerBuilderAgent) Connect(ctx context.Context, execID string, start *
Content: &proto.Content{
Content: &proto.Content_Text{
Text: &proto.TextContent{
- Text: "\n\nBuilding the docker image now...\n",
+ Text: "Building the docker image now...",
},
},
},
@@ -45,7 +45,7 @@ func (a *DockerBuilderAgent) Connect(ctx context.Context, execID string, start *
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",
+ Text: "* us-central1-docker.pkg.dev/acme/test/test:latest is built and is ready to push.",
},
},
},
@@ -59,7 +59,7 @@ func (a *DockerBuilderAgent) Connect(ctx context.Context, execID string, start *
Content: &proto.Content{
Content: &proto.Content_Text{
Text: &proto.TextContent{
- Text: "* The container image is pushed.\n\n",
+ Text: "* The container image is pushed.",
},
},
},
@@ -86,7 +86,7 @@ func (a *DockerMirrorAgent) Connect(ctx context.Context, execID string, start *p
Content: &proto.Content{
Content: &proto.Content_Text{
Text: &proto.TextContent{
- Text: "* Starting pushing docker image now...\n",
+ Text: "* Starting pushing docker image now...",
},
},
},
@@ -100,7 +100,7 @@ func (a *DockerMirrorAgent) Connect(ctx context.Context, execID string, start *p
Content: &proto.Content{
Content: &proto.Content_Text{
Text: &proto.TextContent{
- Text: "* The container image is mirrored.\n",
+ Text: "* The container image is mirrored",
},
},
},
diff --git a/proto/ax.pb.go b/proto/ax.pb.go
index bdc57a9..24bcbc2 100644
--- a/proto/ax.pb.go
+++ b/proto/ax.pb.go
@@ -1158,6 +1158,7 @@ func (x *ExecRequest) GetAgentConfig() *anypb.Any {
type ExecResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Outputs []*Message `protobuf:"bytes,1,rep,name=outputs,proto3" json:"outputs,omitempty"` // Output content
+ Seq int32 `protobuf:"varint,2,opt,name=seq,proto3" json:"seq,omitempty"` // Seq of the outputs
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -1199,6 +1200,13 @@ func (x *ExecResponse) GetOutputs() []*Message {
return nil
}
+func (x *ExecResponse) GetSeq() int32 {
+ if x != nil {
+ return x.Seq
+ }
+ return 0
+}
+
type ForkRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
@@ -1601,9 +1609,10 @@ const file_proto_ax_proto_rawDesc = "" +
"\x06inputs\x18\x02 \x03(\v2\x0e.proto.MessageR\x06inputs\x12\"\n" +
"\rlast_seen_seq\x18\x03 \x01(\x05R\vlastSeenSeq\x12\x19\n" +
"\bagent_id\x18\x04 \x01(\tR\aagentId\x127\n" +
- "\fagent_config\x18\x05 \x01(\v2\x14.google.protobuf.AnyR\vagentConfig\"8\n" +
+ "\fagent_config\x18\x05 \x01(\v2\x14.google.protobuf.AnyR\vagentConfig\"J\n" +
"\fExecResponse\x12(\n" +
- "\aoutputs\x18\x01 \x03(\v2\x0e.proto.MessageR\aoutputs\"\r\n" +
+ "\aoutputs\x18\x01 \x03(\v2\x0e.proto.MessageR\aoutputs\x12\x10\n" +
+ "\x03seq\x18\x02 \x01(\x05R\x03seq\"\r\n" +
"\vForkRequest\"\x0e\n" +
"\fForkResponse\"-\n" +
"\x11RemoteAgentConfig\x12\x18\n" +
diff --git a/proto/ax.proto b/proto/ax.proto
index 952a19a..27887cf 100644
--- a/proto/ax.proto
+++ b/proto/ax.proto
@@ -168,8 +168,7 @@ message ExecRequest {
// ExecResponse contains the result of an execution.
message ExecResponse {
repeated Message outputs = 1; // Output content
- // TODO: int32 seq = 2;
- // TODO: State state = 3;
+ int32 seq = 2; // Seq of the outputs
}
message ForkRequest {