(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, o agent.OutputHandler)
| 49 | } |
| 50 | |
| 51 | func (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 | |
| 84 | func (de *defaultExecutor) exec( |
| 85 | ctx context.Context, |
nothing calls this directly
no test coverage detected