MCPcopy
hub / github.com/google/ax / Exec

Method Exec

internal/controller/executor/executor.go:51–82  ·  view source on GitHub ↗
(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, o agent.OutputHandler)

Source from the content-addressed store, hash-verified

49}
50
51func (de *defaultExecutor) Exec(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, o agent.OutputHandler) (proto.State, error) {
52 execID = newExecID(de.execID, execID)
53 a, ok := de.registry[start.AgentId]
54 if !ok {
55 return proto.State_STATE_UNSPECIFIED, errors.New("no agent found")
56 }
57
58 allInputs, state, earlierAgentID, err := history(ctx, de.eventLog, execID)
59 if err != nil {
60 return proto.State_STATE_UNSPECIFIED, err
61 }
62
63 if msg := historyutil.WaitsForConfirmation(allInputs); msg != nil {
64 // Ensure that the inputs contain the answer to the
65 // confirmation to continue.
66 _, conf := historyutil.HasConfirmationAnswer(start.Messages)
67 if conf == nil {
68 return proto.State_STATE_PENDING, o(&proto.AgentOutputs{
69 Messages: []*proto.Message{msg},
70 })
71 }
72 }
73
74 if earlierAgentID != "" && earlierAgentID != start.AgentId {
75 return proto.State_STATE_UNSPECIFIED, fmt.Errorf("resumption not allowed: agent ID changed from %s to %s", earlierAgentID, start.AgentId)
76 }
77
78 if state == proto.State_STATE_COMPLETED {
79 return proto.State_STATE_COMPLETED, nil
80 }
81 return de.exec(ctx, conversationID, execID, start, de.eventLog, a, allInputs, o)
82}
83
84func (de *defaultExecutor) exec(
85 ctx context.Context,

Callers

nothing calls this directly

Calls 5

execMethod · 0.95
WaitsForConfirmationFunction · 0.92
HasConfirmationAnswerFunction · 0.92
newExecIDFunction · 0.85
historyFunction · 0.85

Tested by

no test coverage detected